Home | History | Annotate | Download | only in fb
      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_DEVICE_H__
     26 #define __HW_DEVICE_H__
     27 
     28 #include <errno.h>
     29 #include <linux/msm_mdp_ext.h>
     30 #include <linux/mdss_rotator.h>
     31 #include <pthread.h>
     32 #include <vector>
     33 
     34 #include "hw_interface.h"
     35 #include "hw_scale.h"
     36 
     37 #define IOCTL_LOGE(ioctl, type) DLOGE("ioctl %s, device = %d errno = %d, desc = %s", #ioctl, \
     38                                       type, errno, strerror(errno))
     39 
     40 #ifndef MDP_LAYER_MULTIRECT_ENABLE
     41 #define MDP_LAYER_MULTIRECT_ENABLE 0
     42 #endif
     43 
     44 #ifndef MDP_LAYER_MULTIRECT_PARALLEL_MODE
     45 #define MDP_LAYER_MULTIRECT_PARALLEL_MODE 0
     46 #endif
     47 
     48 namespace sdm {
     49 class HWInfoInterface;
     50 
     51 class HWDevice : public HWInterface {
     52  protected:
     53   explicit HWDevice(BufferSyncHandler *buffer_sync_handler);
     54   virtual ~HWDevice() {}
     55 
     56   // From HWInterface
     57   virtual DisplayError GetActiveConfig(uint32_t *active_config);
     58   virtual DisplayError GetNumDisplayAttributes(uint32_t *count);
     59   virtual DisplayError GetDisplayAttributes(uint32_t index,
     60                                             HWDisplayAttributes *display_attributes);
     61   virtual DisplayError GetHWPanelInfo(HWPanelInfo *panel_info);
     62   virtual DisplayError SetDisplayAttributes(uint32_t index);
     63   virtual DisplayError SetDisplayAttributes(const HWDisplayAttributes &display_attributes);
     64   virtual DisplayError GetConfigIndex(uint32_t mode, uint32_t *index);
     65   virtual DisplayError PowerOn();
     66   virtual DisplayError PowerOff();
     67   virtual DisplayError Doze();
     68   virtual DisplayError DozeSuspend();
     69   virtual DisplayError Standby();
     70   virtual DisplayError Validate(HWLayers *hw_layers);
     71   virtual DisplayError Commit(HWLayers *hw_layers);
     72   virtual DisplayError Flush();
     73   virtual DisplayError GetPPFeaturesVersion(PPFeatureVersion *vers);
     74   virtual DisplayError SetPPFeatures(PPFeaturesConfig *feature_list);
     75   virtual DisplayError SetVSyncState(bool enable);
     76   virtual void SetIdleTimeoutMs(uint32_t timeout_ms);
     77   virtual DisplayError SetDisplayMode(const HWDisplayMode hw_display_mode);
     78   virtual DisplayError SetRefreshRate(uint32_t refresh_rate);
     79   virtual DisplayError SetPanelBrightness(int level);
     80   virtual DisplayError GetHWScanInfo(HWScanInfo *scan_info);
     81   virtual DisplayError GetVideoFormat(uint32_t config_index, uint32_t *video_format);
     82   virtual DisplayError GetMaxCEAFormat(uint32_t *max_cea_format);
     83   virtual DisplayError SetCursorPosition(HWLayers *hw_layers, int x, int y);
     84   virtual DisplayError OnMinHdcpEncryptionLevelChange(uint32_t min_enc_level);
     85   virtual DisplayError GetPanelBrightness(int *level);
     86   virtual DisplayError SetAutoRefresh(bool enable) { return kErrorNone; }
     87   virtual DisplayError SetS3DMode(HWS3DMode s3d_mode);
     88   virtual DisplayError SetScaleLutConfig(HWScaleLutInfo *lut_info);
     89   virtual DisplayError SetMixerAttributes(const HWMixerAttributes &mixer_attributes);
     90   virtual DisplayError GetMixerAttributes(HWMixerAttributes *mixer_attributes);
     91 
     92   // For HWDevice derivatives
     93   virtual DisplayError Init();
     94   virtual DisplayError Deinit();
     95 
     96   enum {
     97     kHWEventVSync,
     98     kHWEventBlank,
     99   };
    100 
    101   static const int kMaxStringLength = 1024;
    102   static const int kNumPhysicalDisplays = 2;
    103 
    104   void DumpLayerCommit(const mdp_layer_commit &layer_commit);
    105   DisplayError SetFormat(const LayerBufferFormat &source, uint32_t *target);
    106   DisplayError SetStride(HWDeviceType device_type, LayerBufferFormat format,
    107                          uint32_t width, uint32_t *target);
    108   void SetBlending(const LayerBlending &source, mdss_mdp_blend_op *target);
    109   void SetRect(const LayerRect &source, mdp_rect *target);
    110   void SetMDPFlags(const Layer *layer, const bool &is_rotator_used,
    111                    bool is_cursor_pipe_used, uint32_t *mdp_flags);
    112   // Retrieves HW FrameBuffer Node Index
    113   int GetFBNodeIndex(HWDeviceType device_type);
    114   // Populates HWPanelInfo based on node index
    115   void PopulateHWPanelInfo();
    116   void GetHWPanelInfoByNode(int device_node, HWPanelInfo *panel_info);
    117   void GetHWPanelNameByNode(int device_node, HWPanelInfo *panel_info);
    118   void GetHWDisplayPortAndMode(int device_node, HWDisplayPort *port, HWDisplayMode *mode);
    119   void GetSplitInfo(int device_node, HWPanelInfo *panel_info);
    120   void GetHWPanelMaxBrightnessFromNode(HWPanelInfo *panel_info);
    121   int ParseLine(const char *input, char *tokens[], const uint32_t max_token, uint32_t *count);
    122   int ParseLine(const char *input, const char *delim, char *tokens[],
    123                 const uint32_t max_token, uint32_t *count);
    124   void ResetDisplayParams();
    125   void SetCSC(const LayerCSC source, mdp_color_space *color_space);
    126   void SetIGC(const LayerBuffer *layer_buffer, uint32_t index);
    127 
    128   bool EnableHotPlugDetection(int enable);
    129   ssize_t SysFsWrite(const char* file_node, const char* value, ssize_t length);
    130 
    131   HWResourceInfo hw_resource_;
    132   HWPanelInfo hw_panel_info_;
    133   HWInfoInterface *hw_info_intf_;
    134   int fb_node_index_;
    135   const char *fb_path_;
    136   BufferSyncHandler *buffer_sync_handler_;
    137   int device_fd_;
    138   HWDeviceType device_type_;
    139   mdp_layer_commit mdp_disp_commit_;
    140   mdp_input_layer mdp_in_layers_[kMaxSDELayers * 2];   // split panel (left + right)
    141   HWScale *hw_scale_ = NULL;
    142   mdp_overlay_pp_params pp_params_[kMaxSDELayers * 2];
    143   mdp_igc_lut_data_v1_7 igc_lut_data_[kMaxSDELayers * 2];
    144   mdp_output_layer mdp_out_layer_;
    145   const char *device_name_;
    146   bool synchronous_commit_;
    147   HWDisplayAttributes display_attributes_ = {};
    148   HWMixerAttributes mixer_attributes_ = {};
    149   std::vector<mdp_destination_scaler_data> mdp_dest_scalar_data_;
    150 };
    151 
    152 }  // namespace sdm
    153 
    154 #endif  // __HW_DEVICE_H__
    155 
    156