• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (c) 2021, The Linux Foundataion. All rights reserved.
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * met:
6 *     * Redistributions of source code must retain the above copyright
7 *       notice, this list of conditions and the following disclaimer.
8 *     * Redistributions in binary form must reproduce the above
9 *       copyright notice, this list of conditions and the following
10 *       disclaimer in the documentation and/or other materials provided
11 *       with the distribution.
12 *     * Neither the name of The Linux Foundation nor the names of its
13 *       contributors may be used to endorse or promote products derived
14 *       from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 */
29 
30 #ifndef __DRM_PANEL_FEATURE_MGR_H__
31 #define __DRM_PANEL_FEATURE_MGR_H__
32 
33 #include <vector>
34 #include <mutex>
35 
36 #include "drm_interface.h"
37 #include "drm_property.h"
38 #include "drm_panel_feature_mgr_intf.h"
39 
40 namespace sde_drm {
41 
42 class DRMPanelFeatureMgr : public DRMPanelFeatureMgrIntf {
43  public:
~DRMPanelFeatureMgr()44   virtual ~DRMPanelFeatureMgr() {}
45   void Init(int fd, drmModeRes* res);
46   void DeInit();
47   void GetPanelFeatureInfo(DRMPanelFeatureInfo *info);
48   void CachePanelFeature(const DRMPanelFeatureInfo &info);
49   void CommitPanelFeatures(drmModeAtomicReq *req, const DRMDisplayToken &tok);
50 
51  private:
52   int InitObjectProps(int obj_id, int obj_type);
53   void ParseCapabilities(uint32_t blob_id, char* value, uint32_t max_len, const std::string str);
54   void ParseDsppCapabilities(uint32_t blob_id, std::vector<int> *values, uint32_t *size,
55                              const std::string str);
56 
57   std::mutex lock_;
58   int dev_fd_ = -1;
59   drmModeRes* drm_res_ = nullptr;
60   DRMPropertyManager prop_mgr_ {};
61   std::array<std::pair<bool, struct DRMPanelFeatureInfo>,
62           kDRMPanelFeatureMax> dirty_features_ {};
63   std::map<DRMPanelFeatureID, DRMProperty> drm_property_map_ {};
64   std::map<DRMPanelFeatureID, DRMPropType> drm_prop_type_map_ {};
65   std::map<DRMPanelFeatureID, uint32_t> drm_prop_blob_ids_map_ {};
66   std::array<DRMPanelFeatureInfo, kDRMPanelFeatureMax> feature_info_tbl_ {};
67 };
68 
69 /*
70 Below structure is required for cross compatibility between
71 different kernel versions.
72 This structure needs to be in sync with kernel structure.
73 */
74 
75 #define RC_DATA_SIZE_MAX   2720
76 #define RC_CFG_SIZE_MAX       4
77 
78 struct msm_rc_mask_cfg {
79   __u64 flags;
80   __u32 cfg_param_01;
81   __u32 cfg_param_02;
82   __u32 cfg_param_03;
83   __u32 cfg_param_04[RC_CFG_SIZE_MAX];
84   __u32 cfg_param_05[RC_CFG_SIZE_MAX];
85   __u32 cfg_param_06[RC_CFG_SIZE_MAX];
86   __u64 cfg_param_07;
87   __u32 cfg_param_08;
88   __u64 cfg_param_09[RC_DATA_SIZE_MAX];
89 };
90 
91 }  // namespace sde_drm
92 
93 #endif  // __DRM_PANEL_FEATURE_MGR_H__
94 
95