1/* 2* Copyright (c) 2015 - 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_HDMI_H__ 26#define __HW_HDMI_H__ 27 28#include <video/msm_hdmi_modes.h> 29#include <map> 30#include <vector> 31 32#include "hw_device.h" 33 34namespace sdm { 35 36using std::vector; 37 38class HWHDMI : public HWDevice { 39 public: 40 HWHDMI(BufferSyncHandler *buffer_sync_handler, HWInfoInterface *hw_info_intf); 41 42 protected: 43 enum HWFramerateUpdate { 44 // Switch framerate by switch to other standard modes though panel blank/unblank 45 kModeSuspendResume, 46 // Switch framerate by tuning pixel clock 47 kModeClock, 48 // Switch framerate by tuning vertical front porch 49 kModeVFP, 50 // Switch framerate by tuning horizontal front porch 51 kModeHFP, 52 // Switch framerate by tuning horizontal front porch and clock 53 kModeClockHFP, 54 // Switch framerate by tuning horizontal front porch and re-caculate clock 55 kModeHFPCalcClock, 56 kModeMAX 57 }; 58 59 /** 60 * struct DynamicFPSData - defines dynamic fps related data 61 * @hor_front_porch: horizontal front porch 62 * @hor_back_porch: horizontal back porch 63 * @hor_pulse_width: horizontal pulse width 64 * @clk_rate_hz: panel clock rate in HZ 65 * @fps: frames per second 66 */ 67 struct DynamicFPSData { 68 uint32_t hor_front_porch; 69 uint32_t hor_back_porch; 70 uint32_t hor_pulse_width; 71 uint32_t clk_rate_hz; 72 uint32_t fps; 73 }; 74 75 virtual DisplayError Init(); 76 virtual DisplayError GetNumDisplayAttributes(uint32_t *count); 77 // Requirement to call this only after the first config has been explicitly set by client 78 virtual DisplayError GetActiveConfig(uint32_t *active_config); 79 virtual DisplayError GetDisplayAttributes(uint32_t index, 80 HWDisplayAttributes *display_attributes); 81 virtual DisplayError GetHWScanInfo(HWScanInfo *scan_info); 82 virtual DisplayError GetVideoFormat(uint32_t config_index, uint32_t *video_format); 83 virtual DisplayError GetMaxCEAFormat(uint32_t *max_cea_format); 84 virtual DisplayError OnMinHdcpEncryptionLevelChange(uint32_t min_enc_level); 85 virtual DisplayError SetDisplayAttributes(uint32_t index); 86 virtual DisplayError GetConfigIndex(uint32_t mode, uint32_t *index); 87 virtual DisplayError Validate(HWLayers *hw_layers); 88 virtual DisplayError Commit(HWLayers *hw_layers); 89 virtual DisplayError SetS3DMode(HWS3DMode s3d_mode); 90 virtual DisplayError SetRefreshRate(uint32_t refresh_rate); 91 92 private: 93 DisplayError ReadEDIDInfo(); 94 void ReadScanInfo(); 95 HWScanSupport MapHWScanSupport(uint32_t value); 96 int OpenResolutionFile(int file_mode); 97 void RequestNewPage(uint32_t page_number); 98 DisplayError ReadTimingInfo(); 99 bool ReadResolutionFile(char *config_buffer); 100 bool IsResolutionFilePresent(); 101 void SetSourceProductInformation(const char *node, const char *name); 102 DisplayError GetDisplayS3DSupport(uint32_t index, 103 HWDisplayAttributes *attrib); 104 DisplayError GetPanelS3DMode(); 105 bool IsSupportedS3DMode(HWS3DMode s3d_mode); 106 void UpdateMixerAttributes(); 107 DisplayError UpdateHDRMetaData(HWLayers *hw_layers); 108 109 DisplayError GetDynamicFrameRateMode(uint32_t refresh_rate, uint32_t*mode, 110 DynamicFPSData *data, uint32_t *config_index); 111 static const int kThresholdRefreshRate = 1000; 112 vector<uint32_t> hdmi_modes_; 113 // Holds the hdmi timing information. Ex: resolution, fps etc., 114 vector<msm_hdmi_mode_timing_info> supported_video_modes_; 115 HWScanInfo hw_scan_info_; 116 uint32_t active_config_index_; 117 std::map<HWS3DMode, msm_hdmi_s3d_mode> s3d_mode_sdm_to_mdp_; 118 vector<HWS3DMode> supported_s3d_modes_; 119 msm_hdmi_s3d_mode active_mdp_s3d_mode_ = HDMI_S3D_NONE; 120 uint32_t frame_rate_ = 0; 121}; 122 123} // namespace sdm 124 125#endif // __HW_HDMI_H__ 126 127