blob: 0794b94a3319113797e27185c6e49170083d550d [file] [log] [blame]
Naseer Ahmedb92e73f2016-03-12 02:03:48 -05001/*
Sushil Chauhan80e360f2018-03-19 14:00:23 -07002 * Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
Naseer Ahmedb92e73f2016-03-12 02:03:48 -05003 *
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
Arun Kumar K.R29cd6582016-05-10 19:12:45 -070033#include <string>
34
Naseer Ahmedb92e73f2016-03-12 02:03:48 -050035#include "cpuhint.h"
36#include "hwc_display.h"
37
38namespace sdm {
39
40class 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,
Arun Kumar K.R536c7d62016-06-14 18:47:39 -070048 SET_QDCM_SOLID_FILL_RECT,
Naseer Ahmedb92e73f2016-03-12 02:03:48 -050049 };
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();
Ramkumar Radhakrishnan9ec95472018-07-25 20:36:16 -070056 virtual int Deinit();
Naseer Ahmedb92e73f2016-03-12 02:03:48 -050057 virtual HWC2::Error Validate(uint32_t *out_num_types, uint32_t *out_num_requests);
58 virtual HWC2::Error Present(int32_t *out_retire_fence);
Naseer Ahmed5a73a6a2018-04-27 19:17:09 -040059 virtual HWC2::Error GetColorModes(uint32_t *out_num_modes, ColorMode *out_modes);
60 virtual HWC2::Error SetColorMode(ColorMode mode);
linpetera6547752018-12-25 20:02:31 +080061 virtual HWC2::Error SetWhiteCompensation(bool enabled);
Naseer Ahmed5a73a6a2018-04-27 19:17:09 -040062 virtual HWC2::Error GetRenderIntents(ColorMode mode, uint32_t *out_num_intents,
63 RenderIntent *out_intents);
64 virtual HWC2::Error SetColorModeWithRenderIntent(ColorMode mode, RenderIntent intent);
Naseer Ahmed6776dae2017-05-09 11:49:41 -040065 virtual HWC2::Error SetColorModeById(int32_t color_mode_id);
Arun Kumar K.R29cd6582016-05-10 19:12:45 -070066 virtual HWC2::Error SetColorTransform(const float *matrix, android_color_transform_t hint);
Ch Ganesh Kumar5d43ff62017-10-13 19:01:47 +053067 virtual HWC2::Error RestoreColorTransform();
Naseer Ahmedb92e73f2016-03-12 02:03:48 -050068 virtual int Perform(uint32_t operation, ...);
69 virtual void SetSecureDisplay(bool secure_display_active);
70 virtual DisplayError Refresh();
71 virtual void SetIdleTimeoutMs(uint32_t timeout_ms);
Sushil Chauhandc58f2f2018-06-06 18:41:47 -070072 virtual HWC2::Error SetFrameDumpConfig(uint32_t count, uint32_t bit_mask_layer_type,
73 int32_t format, bool post_processed);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -050074 virtual int FrameCaptureAsync(const BufferInfo &output_buffer_info, bool post_processed);
Sushil Chauhan80e360f2018-03-19 14:00:23 -070075 virtual bool GetFrameCaptureFence(int32_t *release_fence);
Alan Kwong2e136332016-08-16 07:50:16 -040076 virtual DisplayError SetDetailEnhancerConfig(const DisplayDetailEnhancerData &de_data);
Arun Kumar K.R17bbd042016-06-07 17:38:02 -070077 virtual DisplayError ControlPartialUpdate(bool enable, uint32_t *pending);
Sushil Chauhan80e360f2018-03-19 14:00:23 -070078 virtual HWC2::Error SetReadbackBuffer(const native_handle_t *buffer, int32_t acquire_fence,
79 bool post_processed_output);
80 virtual HWC2::Error GetReadbackBufferFence(int32_t *release_fence);
Ramkumar Radhakrishnan9ec95472018-07-25 20:36:16 -070081 virtual HWC2::Error PostCommitLayerStack(int32_t *out_retire_fence);
Ramkumar Radhakrishnan7ef1a992018-08-08 13:55:08 -070082 virtual HWC2::Error ControlIdlePowerCollapse(bool enable, bool synchronous);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -050083
84 private:
85 HWCDisplayPrimary(CoreInterface *core_intf, BufferAllocator *buffer_allocator,
86 HWCCallbacks *callbacks, qService::QService *qservice);
87 void SetMetaDataRefreshRateFlag(bool enable);
88 virtual DisplayError SetDisplayMode(uint32_t mode);
Arun Kumar K.R17bbd042016-06-07 17:38:02 -070089 virtual DisplayError DisablePartialUpdateOneFrame();
Naseer Ahmedb92e73f2016-03-12 02:03:48 -050090 void ProcessBootAnimCompleted(void);
Gopikrishnaiah Anandancc123062017-07-31 17:21:03 -070091 void SetQDCMSolidFillInfo(bool enable, const LayerSolidFill &color);
Naseer Ahmedb92e73f2016-03-12 02:03:48 -050092 void ToggleCPUHint(bool set);
93 void ForceRefreshRate(uint32_t refresh_rate);
94 uint32_t GetOptimalRefreshRate(bool one_updating_layer);
95 void HandleFrameOutput();
Naseer Ahmedb92e73f2016-03-12 02:03:48 -050096 void HandleFrameDump();
Arun Kumar K.R8da7f502016-06-07 17:45:50 -070097 DisplayError SetMixerResolution(uint32_t width, uint32_t height);
98 DisplayError GetMixerResolution(uint32_t *width, uint32_t *height);
Ramkumar Radhakrishnan9ec95472018-07-25 20:36:16 -070099 class PMICInterface {
100 public:
101 PMICInterface() { }
102 ~PMICInterface() { }
103 DisplayError Init();
104 void Deinit();
105 DisplayError Notify(bool secure_display_start);
106
107 private:
108 int fd_lcd_bias_ = -1;
109 int fd_wled_ = -1;
110 };
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500111
112 BufferAllocator *buffer_allocator_ = nullptr;
113 CPUHint *cpu_hint_ = nullptr;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500114
Sushil Chauhan80e360f2018-03-19 14:00:23 -0700115 // Primary readback buffer configuration
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500116 LayerBuffer output_buffer_ = {};
117 bool post_processed_output_ = false;
Sushil Chauhan80e360f2018-03-19 14:00:23 -0700118 bool readback_buffer_queued_ = false;
119 bool readback_configured_ = false;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500120
121 // Members for N frame output dump to file
122 bool dump_output_to_file_ = false;
123 BufferInfo output_buffer_info_ = {};
124 void *output_buffer_base_ = nullptr;
Ch Ganesh Kumar86c46512017-06-13 13:09:22 +0530125 int default_mode_status_ = 0;
Ramkumar Radhakrishnan9ec95472018-07-25 20:36:16 -0700126 // PMIC interface to notify secure display start/end
127 PMICInterface *pmic_intf_ = nullptr;
128 bool pmic_notification_pending_ = false;
Naseer Ahmedb92e73f2016-03-12 02:03:48 -0500129};
130
131} // namespace sdm
132
133#endif // __HWC_DISPLAY_PRIMARY_H__