1/* 2* Copyright (c) 2014 - 2017, The Linux Foundation. All rights reserved. 3* 4* Redistribution and use in source and binary forms, with or without modification, are permitted 5* provided that the following conditions are met: 6* * Redistributions of source code must retain the above copyright notice, this list of 7* conditions and the following disclaimer. 8* * Redistributions in binary form must reproduce the above copyright notice, this list of 9* conditions and the following disclaimer in the documentation and/or other materials provided 10* with the distribution. 11* * Neither the name of The Linux Foundation nor the names of its contributors may be used to 12* endorse or promote products derived from this software without specific prior written 13* permission. 14* 15* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 18* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 19* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 20* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 21* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23*/ 24 25#ifndef __HW_INTERFACE_H__ 26#define __HW_INTERFACE_H__ 27 28#include <core/display_interface.h> 29#include <private/hw_info_types.h> 30#include <private/color_interface.h> 31#include <utils/constants.h> 32#include <core/buffer_sync_handler.h> 33 34#include "hw_info_interface.h" 35 36namespace sdm { 37 38enum HWScanSupport { 39 kScanNotSupported, 40 kScanAlwaysOverscanned, 41 kScanAlwaysUnderscanned, 42 kScanBoth, 43}; 44 45struct HWScanInfo { 46 HWScanSupport pt_scan_support; // Scan support for preferred timing 47 HWScanSupport it_scan_support; // Scan support for digital monitor or industry timings 48 HWScanSupport cea_scan_support; // Scan support for CEA resolution timings 49 50 HWScanInfo() : pt_scan_support(kScanNotSupported), it_scan_support(kScanNotSupported), 51 cea_scan_support(kScanNotSupported) { } 52}; 53 54// HWEventHandler - Implemented in DisplayBase and HWInterface implementation 55class HWEventHandler { 56 public: 57 virtual DisplayError VSync(int64_t timestamp) = 0; 58 virtual DisplayError Blank(bool blank) = 0; 59 virtual void IdleTimeout() = 0; 60 virtual void ThermalEvent(int64_t thermal_level) = 0; 61 virtual void CECMessage(char *message) = 0; 62 virtual void IdlePowerCollapse() = 0; 63 virtual void PingPongTimeout() = 0; 64 65 protected: 66 virtual ~HWEventHandler() { } 67}; 68 69class HWInterface { 70 public: 71 static DisplayError Create(DisplayType type, HWInfoInterface *hw_info_intf, 72 BufferSyncHandler *buffer_sync_handler, HWInterface **intf); 73 static DisplayError Destroy(HWInterface *intf); 74 75 virtual DisplayError Init() = 0; 76 virtual DisplayError Deinit() = 0; 77 virtual DisplayError GetActiveConfig(uint32_t *active_config) = 0; 78 virtual DisplayError GetNumDisplayAttributes(uint32_t *count) = 0; 79 virtual DisplayError GetDisplayAttributes(uint32_t index, 80 HWDisplayAttributes *display_attributes) = 0; 81 virtual DisplayError GetHWPanelInfo(HWPanelInfo *panel_info) = 0; 82 virtual DisplayError SetDisplayAttributes(uint32_t index) = 0; 83 virtual DisplayError SetDisplayAttributes(const HWDisplayAttributes &display_attributes) = 0; 84 virtual DisplayError GetConfigIndex(uint32_t mode, uint32_t *index) = 0; 85 virtual DisplayError PowerOn() = 0; 86 virtual DisplayError PowerOff() = 0; 87 virtual DisplayError Doze() = 0; 88 virtual DisplayError DozeSuspend() = 0; 89 virtual DisplayError Standby() = 0; 90 virtual DisplayError Validate(HWLayers *hw_layers) = 0; 91 virtual DisplayError Commit(HWLayers *hw_layers) = 0; 92 virtual DisplayError Flush() = 0; 93 virtual DisplayError GetPPFeaturesVersion(PPFeatureVersion *vers) = 0; 94 virtual DisplayError SetPPFeatures(PPFeaturesConfig *feature_list) = 0; 95 virtual DisplayError SetVSyncState(bool enable) = 0; 96 virtual void SetIdleTimeoutMs(uint32_t timeout_ms) = 0; 97 virtual DisplayError SetDisplayMode(const HWDisplayMode hw_display_mode) = 0; 98 virtual DisplayError SetRefreshRate(uint32_t refresh_rate) = 0; 99 virtual DisplayError SetPanelBrightness(int level) = 0; 100 virtual DisplayError CachePanelBrightness(int level) = 0; 101 virtual DisplayError GetHWScanInfo(HWScanInfo *scan_info) = 0; 102 virtual DisplayError GetVideoFormat(uint32_t config_index, uint32_t *video_format) = 0; 103 virtual DisplayError GetMaxCEAFormat(uint32_t *max_cea_format) = 0; 104 virtual DisplayError SetCursorPosition(HWLayers *hw_layers, int x, int y) = 0; 105 virtual DisplayError OnMinHdcpEncryptionLevelChange(uint32_t min_enc_level) = 0; 106 virtual DisplayError GetPanelBrightness(int *level) = 0; 107 virtual DisplayError SetAutoRefresh(bool enable) = 0; 108 virtual DisplayError SetS3DMode(HWS3DMode s3d_mode) = 0; 109 virtual DisplayError SetScaleLutConfig(HWScaleLutInfo *lut_info) = 0; 110 virtual DisplayError SetMixerAttributes(const HWMixerAttributes &mixer_attributes) = 0; 111 virtual DisplayError GetMixerAttributes(HWMixerAttributes *mixer_attributes) = 0; 112 virtual DisplayError DumpDebugData() = 0; 113 114 protected: 115 virtual ~HWInterface() { } 116}; 117 118} // namespace sdm 119 120#endif // __HW_INTERFACE_H__ 121 122