Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 1 | /* |
Sushil Chauhan | 80e360f | 2018-03-19 14:00:23 -0700 | [diff] [blame] | 2 | * Copyright (c) 2014-2018, The Linux Foundation. All rights reserved. |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 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 | |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 33 | #include <string> |
| 34 | |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 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, |
Arun Kumar K.R | 536c7d6 | 2016-06-14 18:47:39 -0700 | [diff] [blame] | 48 | SET_QDCM_SOLID_FILL_RECT, |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 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(); |
Ramkumar Radhakrishnan | 9ec9547 | 2018-07-25 20:36:16 -0700 | [diff] [blame] | 56 | virtual int Deinit(); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 57 | 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 Ahmed | 5a73a6a | 2018-04-27 19:17:09 -0400 | [diff] [blame] | 59 | virtual HWC2::Error GetColorModes(uint32_t *out_num_modes, ColorMode *out_modes); |
| 60 | virtual HWC2::Error SetColorMode(ColorMode mode); |
linpeter | a654775 | 2018-12-25 20:02:31 +0800 | [diff] [blame^] | 61 | virtual HWC2::Error SetWhiteCompensation(bool enabled); |
Naseer Ahmed | 5a73a6a | 2018-04-27 19:17:09 -0400 | [diff] [blame] | 62 | 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 Ahmed | 6776dae | 2017-05-09 11:49:41 -0400 | [diff] [blame] | 65 | virtual HWC2::Error SetColorModeById(int32_t color_mode_id); |
Arun Kumar K.R | 29cd658 | 2016-05-10 19:12:45 -0700 | [diff] [blame] | 66 | virtual HWC2::Error SetColorTransform(const float *matrix, android_color_transform_t hint); |
Ch Ganesh Kumar | 5d43ff6 | 2017-10-13 19:01:47 +0530 | [diff] [blame] | 67 | virtual HWC2::Error RestoreColorTransform(); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 68 | 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 Chauhan | dc58f2f | 2018-06-06 18:41:47 -0700 | [diff] [blame] | 72 | virtual HWC2::Error SetFrameDumpConfig(uint32_t count, uint32_t bit_mask_layer_type, |
| 73 | int32_t format, bool post_processed); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 74 | virtual int FrameCaptureAsync(const BufferInfo &output_buffer_info, bool post_processed); |
Sushil Chauhan | 80e360f | 2018-03-19 14:00:23 -0700 | [diff] [blame] | 75 | virtual bool GetFrameCaptureFence(int32_t *release_fence); |
Alan Kwong | 2e13633 | 2016-08-16 07:50:16 -0400 | [diff] [blame] | 76 | virtual DisplayError SetDetailEnhancerConfig(const DisplayDetailEnhancerData &de_data); |
Arun Kumar K.R | 17bbd04 | 2016-06-07 17:38:02 -0700 | [diff] [blame] | 77 | virtual DisplayError ControlPartialUpdate(bool enable, uint32_t *pending); |
Sushil Chauhan | 80e360f | 2018-03-19 14:00:23 -0700 | [diff] [blame] | 78 | 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 Radhakrishnan | 9ec9547 | 2018-07-25 20:36:16 -0700 | [diff] [blame] | 81 | virtual HWC2::Error PostCommitLayerStack(int32_t *out_retire_fence); |
Ramkumar Radhakrishnan | 7ef1a99 | 2018-08-08 13:55:08 -0700 | [diff] [blame] | 82 | virtual HWC2::Error ControlIdlePowerCollapse(bool enable, bool synchronous); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 83 | |
| 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.R | 17bbd04 | 2016-06-07 17:38:02 -0700 | [diff] [blame] | 89 | virtual DisplayError DisablePartialUpdateOneFrame(); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 90 | void ProcessBootAnimCompleted(void); |
Gopikrishnaiah Anandan | cc12306 | 2017-07-31 17:21:03 -0700 | [diff] [blame] | 91 | void SetQDCMSolidFillInfo(bool enable, const LayerSolidFill &color); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 92 | void ToggleCPUHint(bool set); |
| 93 | void ForceRefreshRate(uint32_t refresh_rate); |
| 94 | uint32_t GetOptimalRefreshRate(bool one_updating_layer); |
| 95 | void HandleFrameOutput(); |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 96 | void HandleFrameDump(); |
Arun Kumar K.R | 8da7f50 | 2016-06-07 17:45:50 -0700 | [diff] [blame] | 97 | DisplayError SetMixerResolution(uint32_t width, uint32_t height); |
| 98 | DisplayError GetMixerResolution(uint32_t *width, uint32_t *height); |
Ramkumar Radhakrishnan | 9ec9547 | 2018-07-25 20:36:16 -0700 | [diff] [blame] | 99 | 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 Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 111 | |
| 112 | BufferAllocator *buffer_allocator_ = nullptr; |
| 113 | CPUHint *cpu_hint_ = nullptr; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 114 | |
Sushil Chauhan | 80e360f | 2018-03-19 14:00:23 -0700 | [diff] [blame] | 115 | // Primary readback buffer configuration |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 116 | LayerBuffer output_buffer_ = {}; |
| 117 | bool post_processed_output_ = false; |
Sushil Chauhan | 80e360f | 2018-03-19 14:00:23 -0700 | [diff] [blame] | 118 | bool readback_buffer_queued_ = false; |
| 119 | bool readback_configured_ = false; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 120 | |
| 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 Kumar | 86c4651 | 2017-06-13 13:09:22 +0530 | [diff] [blame] | 125 | int default_mode_status_ = 0; |
Ramkumar Radhakrishnan | 9ec9547 | 2018-07-25 20:36:16 -0700 | [diff] [blame] | 126 | // PMIC interface to notify secure display start/end |
| 127 | PMICInterface *pmic_intf_ = nullptr; |
| 128 | bool pmic_notification_pending_ = false; |
Naseer Ahmed | b92e73f | 2016-03-12 02:03:48 -0500 | [diff] [blame] | 129 | }; |
| 130 | |
| 131 | } // namespace sdm |
| 132 | |
| 133 | #endif // __HWC_DISPLAY_PRIMARY_H__ |