/*
* Copyright (c) 2019-2020, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*    * Redistributions of source code must retain the above copyright
*      notice, this list of conditions and the following disclaimer.
*    * Redistributions in binary form must reproduce the above
*      copyright notice, this list of conditions and the following
*      disclaimer in the documentation and/or other materials provided
*      with the distribution.
*    * Neither the name of The Linux Foundation nor the names of its
*      contributors may be used to endorse or promote products derived
*      from this software without specific prior written permission.

* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef __DRM_MANAGER_H__
#define __DRM_MANAGER_H__

#include <drm_interface.h>
#include <mutex>
#include "drm_dpps_mgr_intf.h"
#include "drm_panel_feature_mgr_intf.h"

namespace sde_drm {

class DRMAtomicReqInterface;
class DRMPlaneManager;
class DRMPlane;
class DRMConnectorManager;
class DRMEncoderManager;
class DRMConnnector;
class DRMCrtcManager;
class DRMCrtc;

class DRMManager : public DRMManagerInterface {
 public:
  virtual ~DRMManager();
  virtual int RegisterDisplay(DRMDisplayType disp_type, DRMDisplayToken *token);
  virtual int RegisterDisplay(int32_t display_id, DRMDisplayToken *token);
  virtual void UnregisterDisplay(DRMDisplayToken *token);
  virtual void GetPlanesInfo(DRMPlanesInfo *info);
  virtual int GetCrtcInfo(uint32_t crtc_id, DRMCrtcInfo *info);
  virtual int GetConnectorInfo(uint32_t conn_id, DRMConnectorInfo *info);
  virtual int GetConnectorsInfo(DRMConnectorsInfo *infos);
  virtual int GetEncoderInfo(uint32_t encoder_id, DRMEncoderInfo *info);
  virtual int GetEncodersInfo(DRMEncodersInfo *infos);
  virtual void GetCrtcPPInfo(uint32_t crtc_id, DRMPPFeatureInfo *info);
  virtual int CreateAtomicReq(const DRMDisplayToken &token, DRMAtomicReqInterface **intf);
  virtual int DestroyAtomicReq(DRMAtomicReqInterface *intf);
  virtual int SetScalerLUT(const DRMScalerLUTInfo &lut_info);
  virtual int UnsetScalerLUT();
  virtual void GetDppsFeatureInfo(DRMDppsFeatureInfo *info);
  virtual void GetPanelFeature(DRMPanelFeatureInfo *info);
  virtual void SetPanelFeature(const DRMPanelFeatureInfo &info);
  virtual void MapPlaneToConnector(std::map<uint32_t, uint32_t> *plane_to_connector);
  virtual void GetRequiredDemuraFetchResourceCount(std::map<uint32_t, uint8_t>
                                                   *required_demura_fetch_cnt);
  virtual void GetInitialDemuraInfo(std::vector<uint32_t> *initial_demura_planes);
  virtual void MarkPanelFeatureForNullCommit(const DRMDisplayToken &token,
                                             const DRMPanelFeatureID &id);

  DRMPlaneManager *GetPlaneMgr();
  DRMConnectorManager *GetConnectorMgr();
  DRMEncoderManager *GetEncoderMgr();
  DRMCrtcManager *GetCrtcMgr();
  DRMDppsManagerIntf *GetDppsMgrIntf();
  DRMPanelFeatureMgrIntf *GetPanelFeatureMgrIntf();

  static DRMManager *GetInstance(int fd);
  static void Destroy();

 private:
  int Init(int drm_fd);

  int fd_ = -1;
  DRMPlaneManager *plane_mgr_ = {};
  DRMConnectorManager *conn_mgr_ = {};
  DRMEncoderManager *encoder_mgr_ = {};
  DRMCrtcManager *crtc_mgr_ = {};
  DRMDppsManagerIntf *dpps_mgr_intf_ = {};
  DRMPanelFeatureMgrIntf *panel_feature_mgr_intf_ = {};

  static DRMManager *s_drm_instance;
  static std::mutex s_lock;
};

}  // namespace sde_drm
#endif  // __DRM_MANAGER_H__
