1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "ExynosDisplayDrmInterfaceModule.h"
18 #include "ExynosPrimaryDisplayModule.h"
19 
20 using namespace zuma;
21 
22 //////////////////////////////////////////////////// ExynosPrimaryDisplayDrmInterfaceModule //////////////////////////////////////////////////////////////////
ExynosPrimaryDisplayDrmInterfaceModule(ExynosDisplay * exynosDisplay)23 ExynosPrimaryDisplayDrmInterfaceModule::ExynosPrimaryDisplayDrmInterfaceModule(ExynosDisplay *exynosDisplay)
24   : gs201::ExynosPrimaryDisplayDrmInterfaceModule(exynosDisplay)
25 {
26             ExynosPrimaryDisplayModule* display = (ExynosPrimaryDisplayModule*)mExynosDisplay;
27             const std::string& sysfs = display->getPanelSysfsPath();
28             std::string panelModel;
29 
30             if (sysfs.empty()) {
31                 return;
32             }
33 
34             if (readLineFromFile(sysfs + "/panel_model", panelModel, '\n') != OK) {
35                 return;
36             }
37 
38             /*
39              * VESA EDID Standard requires monitor descriptor data to terminate
40              * with '\n' character and to pad with ' ' characters if < 13 bytes.
41              */
42             if (panelModel.size() < MONITOR_DESCRIPTOR_DATA_LENGTH) {
43                 panelModel += '\n';
44                 panelModel.append(MONITOR_DESCRIPTOR_DATA_LENGTH - panelModel.size(), ' ');
45             }
46 
47             if (panelModel.size() > MONITOR_DESCRIPTOR_DATA_LENGTH) {
48                 ALOGE("Panel model longer than maximum %u bytes", MONITOR_DESCRIPTOR_DATA_LENGTH);
49                 return;
50             }
51 
52             std::memcpy(mMonitorDescription.data(), panelModel.c_str(), mMonitorDescription.size());
53 }
54