Home | History | Annotate | Download | only in core
      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 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 
     36 namespace sdm {
     37 
     38 enum HWScanSupport {
     39   kScanNotSupported,
     40   kScanAlwaysOverscanned,
     41   kScanAlwaysUnderscanned,
     42   kScanBoth,
     43 };
     44 
     45 struct 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
     55 class 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 
     63  protected:
     64   virtual ~HWEventHandler() { }
     65 };
     66 
     67 class HWInterface {
     68  public:
     69   static DisplayError Create(DisplayType type, HWInfoInterface *hw_info_intf,
     70                              BufferSyncHandler *buffer_sync_handler, HWInterface **intf);
     71   static DisplayError Destroy(HWInterface *intf);
     72 
     73   virtual DisplayError GetActiveConfig(uint32_t *active_config) = 0;
     74   virtual DisplayError GetNumDisplayAttributes(uint32_t *count) = 0;
     75   virtual DisplayError GetDisplayAttributes(uint32_t index,
     76                                             HWDisplayAttributes *display_attributes) = 0;
     77   virtual DisplayError GetHWPanelInfo(HWPanelInfo *panel_info) = 0;
     78   virtual DisplayError SetDisplayAttributes(uint32_t index) = 0;
     79   virtual DisplayError SetDisplayAttributes(const HWDisplayAttributes &display_attributes) = 0;
     80   virtual DisplayError GetConfigIndex(uint32_t mode, uint32_t *index) = 0;
     81   virtual DisplayError PowerOn() = 0;
     82   virtual DisplayError PowerOff() = 0;
     83   virtual DisplayError Doze() = 0;
     84   virtual DisplayError DozeSuspend() = 0;
     85   virtual DisplayError Standby() = 0;
     86   virtual DisplayError Validate(HWLayers *hw_layers) = 0;
     87   virtual DisplayError Commit(HWLayers *hw_layers) = 0;
     88   virtual DisplayError Flush() = 0;
     89   virtual DisplayError GetPPFeaturesVersion(PPFeatureVersion *vers) = 0;
     90   virtual DisplayError SetPPFeatures(PPFeaturesConfig *feature_list) = 0;
     91   virtual DisplayError SetVSyncState(bool enable) = 0;
     92   virtual void SetIdleTimeoutMs(uint32_t timeout_ms) = 0;
     93   virtual DisplayError SetDisplayMode(const HWDisplayMode hw_display_mode) = 0;
     94   virtual DisplayError SetRefreshRate(uint32_t refresh_rate) = 0;
     95   virtual DisplayError SetPanelBrightness(int level) = 0;
     96   virtual DisplayError GetHWScanInfo(HWScanInfo *scan_info) = 0;
     97   virtual DisplayError GetVideoFormat(uint32_t config_index, uint32_t *video_format) = 0;
     98   virtual DisplayError GetMaxCEAFormat(uint32_t *max_cea_format) = 0;
     99   virtual DisplayError SetCursorPosition(HWLayers *hw_layers, int x, int y) = 0;
    100   virtual DisplayError OnMinHdcpEncryptionLevelChange(uint32_t min_enc_level) = 0;
    101   virtual DisplayError GetPanelBrightness(int *level) = 0;
    102   virtual DisplayError SetAutoRefresh(bool enable) = 0;
    103   virtual DisplayError SetS3DMode(HWS3DMode s3d_mode) = 0;
    104   virtual DisplayError SetScaleLutConfig(HWScaleLutInfo *lut_info) = 0;
    105   virtual DisplayError SetMixerAttributes(const HWMixerAttributes &mixer_attributes) = 0;
    106   virtual DisplayError GetMixerAttributes(HWMixerAttributes *mixer_attributes) = 0;
    107 
    108  protected:
    109   virtual ~HWInterface() { }
    110 };
    111 
    112 }  // namespace sdm
    113 
    114 #endif  // __HW_INTERFACE_H__
    115 
    116