blob: 4fb7cfa019d0a21bd509aabedb59de610d85e88c [file] [log] [blame]
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -07003 * Copyright (C) 2012-2014, The Linux Foundation. All rights reserved.
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -07004 *
5 * Not a Contribution, Apache license notifications and license are
6 * retained for attribution purposes only.
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20
Naseer Ahmed72cf9762012-07-21 12:17:13 -070021#define DEBUG 0
Naseer Ahmed72cf9762012-07-21 12:17:13 -070022#include <fcntl.h>
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -070023#include <linux/msm_mdp.h>
Arun Kumar K.R25187572013-02-28 18:47:36 -080024#include <video/msm_hdmi_modes.h>
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -070025#include <linux/fb.h>
26#include <sys/ioctl.h>
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -070027#include <cutils/properties.h>
28#include "hwc_utils.h"
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -070029#include "hdmi.h"
Saurabh Shah56f610d2012-08-07 15:27:06 -070030#include "overlayUtils.h"
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -080031#include "overlay.h"
Tatenda Chipeperekwaf080b792014-03-05 19:32:33 -080032#include "qd_utils.h"
Saurabh Shah56f610d2012-08-07 15:27:06 -070033
34using namespace android;
Tatenda Chipeperekwace8d5c42014-08-13 10:53:49 -070035using namespace qdutils;
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -070036
37namespace qhwc {
Arun Kumar K.R26808f32013-02-11 19:17:05 -080038#define UNKNOWN_STRING "unknown"
39#define SPD_NAME_LENGTH 16
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -070040
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -070041/* The array gEDIDData contains a list of modes currently
42 * supported by HDMI and display, and modes that are not
43 * supported i.e. interlaced modes.
44
45 * In order to add support for a new mode, the mode must be
46 * appended to the end of the array.
47 *
48 * Each new entry must contain the following:
49 * -Mode: a video format defined in msm_hdmi_modes.h
50 * -Width: x resolution for the mode
51 * -Height: y resolution for the mode
52 * -FPS: the frame rate for the mode
53 * -Mode Order: the priority for the new mode that is used when determining
54 * the best mode when the HDMI display is connected.
55 */
56EDIDData gEDIDData [] = {
57 EDIDData(HDMI_VFRMT_1440x480i60_4_3, 1440, 480, 60, 1),
58 EDIDData(HDMI_VFRMT_1440x480i60_16_9, 1440, 480, 60, 2),
59 EDIDData(HDMI_VFRMT_1440x576i50_4_3, 1440, 576, 50, 3),
60 EDIDData(HDMI_VFRMT_1440x576i50_16_9, 1440, 576, 50, 4),
61 EDIDData(HDMI_VFRMT_1920x1080i60_16_9, 1920, 1080, 60, 5),
62 EDIDData(HDMI_VFRMT_640x480p60_4_3, 640, 480, 60, 6),
63 EDIDData(HDMI_VFRMT_720x480p60_4_3, 720, 480, 60, 7),
64 EDIDData(HDMI_VFRMT_720x480p60_16_9, 720, 480, 60, 8),
65 EDIDData(HDMI_VFRMT_720x576p50_4_3, 720, 576, 50, 9),
66 EDIDData(HDMI_VFRMT_720x576p50_16_9, 720, 576, 50, 10),
Tatenda Chipeperekwa85dcfe52014-09-29 16:34:01 -070067 EDIDData(HDMI_VFRMT_800x600p60_4_3, 800, 600, 60, 11),
68 EDIDData(HDMI_VFRMT_848x480p60_16_9, 848, 480, 60, 12),
69 EDIDData(HDMI_VFRMT_1024x768p60_4_3, 1024, 768, 60, 13),
70 EDIDData(HDMI_VFRMT_1280x1024p60_5_4, 1280, 1024, 60, 14),
71 EDIDData(HDMI_VFRMT_1280x720p50_16_9, 1280, 720, 50, 15),
72 EDIDData(HDMI_VFRMT_1280x720p60_16_9, 1280, 720, 60, 16),
73 EDIDData(HDMI_VFRMT_1280x800p60_16_10, 1280, 800, 60, 17),
74 EDIDData(HDMI_VFRMT_1280x960p60_4_3, 1280, 960, 60, 18),
75 EDIDData(HDMI_VFRMT_1360x768p60_16_9, 1360, 768, 60, 19),
76 EDIDData(HDMI_VFRMT_1366x768p60_16_10, 1366, 768, 60, 20),
77 EDIDData(HDMI_VFRMT_1440x900p60_16_10, 1440, 900, 60, 21),
78 EDIDData(HDMI_VFRMT_1400x1050p60_4_3, 1400, 1050, 60, 22),
79 EDIDData(HDMI_VFRMT_1680x1050p60_16_10, 1680, 1050, 60, 23),
80 EDIDData(HDMI_VFRMT_1600x1200p60_4_3, 1600, 1200, 60, 24),
81 EDIDData(HDMI_VFRMT_1920x1080p24_16_9, 1920, 1080, 24, 25),
82 EDIDData(HDMI_VFRMT_1920x1080p25_16_9, 1920, 1080, 25, 26),
83 EDIDData(HDMI_VFRMT_1920x1080p30_16_9, 1920, 1080, 30, 27),
84 EDIDData(HDMI_VFRMT_1920x1080p50_16_9, 1920, 1080, 50, 28),
85 EDIDData(HDMI_VFRMT_1920x1080p60_16_9, 1920, 1080, 60, 29),
86 EDIDData(HDMI_VFRMT_1920x1200p60_16_10, 1920, 1200, 60, 30),
87 EDIDData(HDMI_VFRMT_2560x1600p60_16_9, 2560, 1600, 60, 31),
88 EDIDData(HDMI_VFRMT_3840x2160p24_16_9, 3840, 2160, 24, 32),
89 EDIDData(HDMI_VFRMT_3840x2160p25_16_9, 3840, 2160, 25, 33),
90 EDIDData(HDMI_VFRMT_3840x2160p30_16_9, 3840, 2160, 30, 34),
91 EDIDData(HDMI_VFRMT_4096x2160p24_16_9, 4096, 2160, 24, 35),
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -070092};
93
94// Number of modes in gEDIDData
95const int gEDIDCount = (sizeof(gEDIDData)/sizeof(gEDIDData)[0]);
96
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -070097int HDMIDisplay::configure() {
Jeykumar Sankaran27dee262013-08-01 17:09:54 -070098 if(!openFrameBuffer()) {
99 ALOGE("%s: Failed to open FB: %d", __FUNCTION__, mFbNum);
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -0800100 return -1;
Jeykumar Sankaran27dee262013-08-01 17:09:54 -0700101 }
Arun Kumar K.Rfeb2d8a2013-02-01 02:53:13 -0800102 readCEUnderscanInfo();
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -0800103 readResolution();
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -0800104 // TODO: Move this to activate
Arun Kumar K.R37552c52012-12-10 12:47:18 -0800105 /* Used for changing the resolution
106 * getUserMode will get the preferred
107 * mode set thru adb shell */
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700108 mCurrentMode = getUserMode();
109 if (mCurrentMode == -1) {
Arun Kumar K.R37552c52012-12-10 12:47:18 -0800110 //Get the best mode and set
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700111 mCurrentMode = getBestMode();
Arun Kumar K.R37552c52012-12-10 12:47:18 -0800112 }
Jeykumar Sankaran27dee262013-08-01 17:09:54 -0700113 setAttributes();
Amara Venkata Mastan Manoj Kumarb156a2f2013-02-07 16:42:50 -0800114 // set system property
115 property_set("hw.hdmiON", "1");
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700116
117 // Read the system property to determine if downscale feature is enabled.
118 char value[PROPERTY_VALUE_MAX];
119 mMDPDownscaleEnabled = false;
120 if(property_get("sys.hwc.mdp_downscale_enabled", value, "false")
121 && !strcmp(value, "true")) {
122 mMDPDownscaleEnabled = true;
123 }
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -0800124 return 0;
125}
126
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -0700127void HDMIDisplay::getAttributes(uint32_t& width, uint32_t& height) {
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700128 uint32_t fps = 0;
Amara Venkata Mastan Manoj Kumar376d8a82013-03-13 19:18:47 -0700129 getAttrForMode(width, height, fps);
130}
131
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -0700132int HDMIDisplay::teardown() {
Jeykumar Sankaran27dee262013-08-01 17:09:54 -0700133 closeFrameBuffer();
134 resetInfo();
135 // unset system property
136 property_set("hw.hdmiON", "0");
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -0800137 return 0;
138}
139
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -0700140HDMIDisplay::HDMIDisplay():mFd(-1),
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700141 mCurrentMode(-1), mModeCount(0), mPrimaryWidth(0), mPrimaryHeight(0),
142 mUnderscanSupported(false)
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700143{
Naseer Ahmedf8ec1622012-07-31 18:56:23 -0700144 memset(&mVInfo, 0, sizeof(mVInfo));
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700145
146 mDisplayId = HWC_DISPLAY_EXTERNAL;
147 // Update the display if HDMI is connected as primary
148 if (isHDMIPrimaryDisplay()) {
149 mDisplayId = HWC_DISPLAY_PRIMARY;
150 }
151
152 mFbNum = overlay::Overlay::getInstance()->getFbForDpy(mDisplayId);
Arun Kumar K.Re746ac52013-03-20 15:56:15 -0700153 // disable HPD at start, it will be enabled later
154 // when the display powers on
155 // This helps for framework reboot or adb shell stop/start
156 writeHPDOption(0);
Amara Venkata Mastan Manoj Kumar11a380d2013-01-17 09:30:56 -0800157
Arun Kumar K.R25187572013-02-28 18:47:36 -0800158 // for HDMI - retreive all the modes supported by the driver
Jeykumar Sankaran27dee262013-08-01 17:09:54 -0700159 if(mFbNum != -1) {
Arun Kumar K.R25187572013-02-28 18:47:36 -0800160 supported_video_mode_lut =
161 new msm_hdmi_mode_timing_info[HDMI_VFRMT_MAX];
162 // Populate the mode table for supported modes
163 MSM_HDMI_MODES_INIT_TIMINGS(supported_video_mode_lut);
164 MSM_HDMI_MODES_SET_SUPP_TIMINGS(supported_video_mode_lut,
165 MSM_HDMI_MODES_ALL);
Arun Kumar K.R26808f32013-02-11 19:17:05 -0800166 // Update the Source Product Information
167 // Vendor Name
168 setSPDInfo("vendor_name", "ro.product.manufacturer");
169 // Product Description
170 setSPDInfo("product_description", "ro.product.name");
171 }
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700172
173 ALOGD_IF(DEBUG, "%s mDisplayId(%d) mFbNum(%d)",
174 __FUNCTION__, mDisplayId, mFbNum);
Arun Kumar K.R26808f32013-02-11 19:17:05 -0800175}
176/* gets the product manufacturer and product name and writes it
177 * to the sysfs node, so that the driver can get that information
178 * Used to show QCOM 8974 instead of Input 1 for example
179 */
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -0700180void HDMIDisplay::setSPDInfo(const char* node, const char* property) {
Arun Kumar K.R26808f32013-02-11 19:17:05 -0800181 char info[PROPERTY_VALUE_MAX];
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700182 ssize_t err = -1;
183 int spdFile = openDeviceNode(node, O_RDWR);
184 if (spdFile >= 0) {
Arun Kumar K.R26808f32013-02-11 19:17:05 -0800185 memset(info, 0, sizeof(info));
186 property_get(property, info, UNKNOWN_STRING);
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700187 ALOGD_IF(DEBUG, "In %s: %s = %s",
188 __FUNCTION__, property, info);
Arun Kumar K.R26808f32013-02-11 19:17:05 -0800189 if (strncmp(info, UNKNOWN_STRING, SPD_NAME_LENGTH)) {
190 err = write(spdFile, info, strlen(info));
191 if (err <= 0) {
192 ALOGE("%s: file write failed for '%s'"
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700193 "err no = %d", __FUNCTION__, node, errno);
Arun Kumar K.R26808f32013-02-11 19:17:05 -0800194 }
195 } else {
196 ALOGD_IF(DEBUG, "%s: property_get failed for SPD %s",
197 __FUNCTION__, node);
198 }
199 close(spdFile);
Arun Kumar K.R25187572013-02-28 18:47:36 -0800200 }
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700201}
202
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -0700203void HDMIDisplay::setHPD(uint32_t value) {
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700204 ALOGD_IF(DEBUG,"HPD enabled=%d", value);
205 writeHPDOption(value);
Saurabh Shah56f610d2012-08-07 15:27:06 -0700206}
207
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -0700208void HDMIDisplay::setActionSafeDimension(int w, int h) {
Saurabh Shah56f610d2012-08-07 15:27:06 -0700209 ALOGD_IF(DEBUG,"ActionSafe w=%d h=%d", w, h);
Arun Kumar K.Rfeb2d8a2013-02-01 02:53:13 -0800210 char actionsafeWidth[PROPERTY_VALUE_MAX];
211 char actionsafeHeight[PROPERTY_VALUE_MAX];
Arun Kumar K.R26808f32013-02-11 19:17:05 -0800212 snprintf(actionsafeWidth, sizeof(actionsafeWidth), "%d", w);
Arun Kumar K.R4d73d642013-04-10 17:06:39 -0700213 property_set("persist.sys.actionsafe.width", actionsafeWidth);
Arun Kumar K.R26808f32013-02-11 19:17:05 -0800214 snprintf(actionsafeHeight, sizeof(actionsafeHeight), "%d", h);
Arun Kumar K.R4d73d642013-04-10 17:06:39 -0700215 property_set("persist.sys.actionsafe.height", actionsafeHeight);
Saurabh Shah56f610d2012-08-07 15:27:06 -0700216}
217
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -0700218int HDMIDisplay::getModeCount() const {
Saurabh Shah56f610d2012-08-07 15:27:06 -0700219 ALOGD_IF(DEBUG,"HPD mModeCount=%d", mModeCount);
Saurabh Shah56f610d2012-08-07 15:27:06 -0700220 return mModeCount;
221}
222
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -0700223void HDMIDisplay::readCEUnderscanInfo()
Arun Kumar K.Rfeb2d8a2013-02-01 02:53:13 -0800224{
225 int hdmiScanInfoFile = -1;
Dileep Kumar Reddibf333c72014-02-25 14:32:51 +0530226 ssize_t len = -1;
Arun Kumar K.Rfeb2d8a2013-02-01 02:53:13 -0800227 char scanInfo[17];
228 char *ce_info_str = NULL;
Ramkumar Radhakrishnan36bd5272014-01-31 20:03:01 -0800229 char *save_ptr;
Arun Kumar K.Rfeb2d8a2013-02-01 02:53:13 -0800230 const char token[] = ", \n";
231 int ce_info = -1;
Arun Kumar K.Rfeb2d8a2013-02-01 02:53:13 -0800232
233 memset(scanInfo, 0, sizeof(scanInfo));
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700234 hdmiScanInfoFile = openDeviceNode("scan_info", O_RDONLY);
Arun Kumar K.Rfeb2d8a2013-02-01 02:53:13 -0800235 if (hdmiScanInfoFile < 0) {
Arun Kumar K.Rfeb2d8a2013-02-01 02:53:13 -0800236 return;
237 } else {
238 len = read(hdmiScanInfoFile, scanInfo, sizeof(scanInfo)-1);
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700239 ALOGD("%s: Scan Info string: %s length = %zu",
Arun Kumar K.Rfeb2d8a2013-02-01 02:53:13 -0800240 __FUNCTION__, scanInfo, len);
241 if (len <= 0) {
242 close(hdmiScanInfoFile);
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700243 ALOGE("%s: Scan Info file empty", __FUNCTION__);
Arun Kumar K.Rfeb2d8a2013-02-01 02:53:13 -0800244 return;
245 }
246 scanInfo[len] = '\0'; /* null terminate the string */
Dileep Kumar Reddibf333c72014-02-25 14:32:51 +0530247 close(hdmiScanInfoFile);
Arun Kumar K.Rfeb2d8a2013-02-01 02:53:13 -0800248 }
Arun Kumar K.Rfeb2d8a2013-02-01 02:53:13 -0800249
250 /*
251 * The scan_info contains the three fields
252 * PT - preferred video format
253 * IT - video format
254 * CE video format - containing the underscan support information
255 */
256
257 /* PT */
Ramkumar Radhakrishnan36bd5272014-01-31 20:03:01 -0800258 ce_info_str = strtok_r(scanInfo, token, &save_ptr);
Arun Kumar K.Rfeb2d8a2013-02-01 02:53:13 -0800259 if (ce_info_str) {
260 /* IT */
Ramkumar Radhakrishnan36bd5272014-01-31 20:03:01 -0800261 ce_info_str = strtok_r(NULL, token, &save_ptr);
Arun Kumar K.Rfeb2d8a2013-02-01 02:53:13 -0800262 if (ce_info_str) {
263 /* CE */
Ramkumar Radhakrishnan36bd5272014-01-31 20:03:01 -0800264 ce_info_str = strtok_r(NULL, token, &save_ptr);
Arun Kumar K.Rfeb2d8a2013-02-01 02:53:13 -0800265 if (ce_info_str)
266 ce_info = atoi(ce_info_str);
267 }
268 }
269
270 if (ce_info_str) {
271 // ce_info contains the underscan information
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -0700272 if (ce_info == HDMI_SCAN_ALWAYS_UNDERSCANED ||
273 ce_info == HDMI_SCAN_BOTH_SUPPORTED)
Arun Kumar K.Rfeb2d8a2013-02-01 02:53:13 -0800274 // if TV supported underscan, then driver will always underscan
275 // hence no need to apply action safe rectangle
276 mUnderscanSupported = true;
277 } else {
278 ALOGE("%s: scan_info string error", __FUNCTION__);
279 }
280
281 // Store underscan support info in a system property
282 const char* prop = (mUnderscanSupported) ? "1" : "0";
283 property_set("hw.underscan_supported", prop);
284 return;
285}
286
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -0700287HDMIDisplay::~HDMIDisplay()
Naseer Ahmed72cf9762012-07-21 12:17:13 -0700288{
Arun Kumar K.R25187572013-02-28 18:47:36 -0800289 delete [] supported_video_mode_lut;
Naseer Ahmedf8ec1622012-07-31 18:56:23 -0700290 closeFrameBuffer();
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700291}
292
Arun Kumar K.R25187572013-02-28 18:47:36 -0800293/*
294 * sets the fb_var_screeninfo from the hdmi_mode_timing_info
295 */
296void setDisplayTiming(struct fb_var_screeninfo &info,
297 const msm_hdmi_mode_timing_info* mode)
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700298{
299 info.reserved[0] = 0;
300 info.reserved[1] = 0;
301 info.reserved[2] = 0;
Ken Zhang7b03a952013-01-16 13:23:48 -0500302#ifndef FB_METADATA_VIDEO_INFO_CODE_SUPPORT
Arun Kumar K.R25187572013-02-28 18:47:36 -0800303 info.reserved[3] = (info.reserved[3] & 0xFFFF) |
304 (mode->video_format << 16);
Ken Zhang7b03a952013-01-16 13:23:48 -0500305#endif
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700306 info.xoffset = 0;
307 info.yoffset = 0;
Arun Kumar K.R25187572013-02-28 18:47:36 -0800308 info.xres = mode->active_h;
309 info.yres = mode->active_v;
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700310
Arun Kumar K.R25187572013-02-28 18:47:36 -0800311 info.pixclock = (mode->pixel_freq)*1000;
312 info.vmode = mode->interlaced ?
313 FB_VMODE_INTERLACED : FB_VMODE_NONINTERLACED;
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700314
Arun Kumar K.R25187572013-02-28 18:47:36 -0800315 info.right_margin = mode->front_porch_h;
316 info.hsync_len = mode->pulse_width_h;
317 info.left_margin = mode->back_porch_h;
318 info.lower_margin = mode->front_porch_v;
319 info.vsync_len = mode->pulse_width_v;
320 info.upper_margin = mode->back_porch_v;
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700321}
322
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -0700323int HDMIDisplay::parseResolution(char* edidStr)
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700324{
325 char delim = ',';
326 int count = 0;
327 char *start, *end;
328 // EDIDs are string delimited by ','
329 // Ex: 16,4,5,3,32,34,1
330 // Parse this string to get mode(int)
331 start = (char*) edidStr;
Naseer Ahmedf8ec1622012-07-31 18:56:23 -0700332 end = &delim;
333 while(*end == delim) {
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700334 mEDIDModes[count] = (int) strtol(start, &end, 10);
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700335 start = end+1;
336 count++;
337 }
Naseer Ahmedf8ec1622012-07-31 18:56:23 -0700338 ALOGD_IF(DEBUG, "In %s: count = %d", __FUNCTION__, count);
339 for (int i = 0; i < count; i++)
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700340 ALOGD_IF(DEBUG, "Mode[%d] = %d", i, mEDIDModes[i]);
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700341 return count;
342}
Naseer Ahmedf8ec1622012-07-31 18:56:23 -0700343
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -0700344bool HDMIDisplay::readResolution()
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700345{
Dileep Kumar Reddibf333c72014-02-25 14:32:51 +0530346 ssize_t len = -1;
Arun Kumar K.R83812342013-09-24 17:30:36 -0700347 char edidStr[128] = {'\0'};
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700348
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700349 int hdmiEDIDFile = openDeviceNode("edid_modes", O_RDONLY);
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700350 if (hdmiEDIDFile < 0) {
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700351 return false;
352 } else {
Arun Kumar K.R83812342013-09-24 17:30:36 -0700353 len = read(hdmiEDIDFile, edidStr, sizeof(edidStr)-1);
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700354 ALOGD_IF(DEBUG, "%s: EDID string: %s length = %zu",
Arun Kumar K.R83812342013-09-24 17:30:36 -0700355 __FUNCTION__, edidStr, len);
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700356 if (len <= 0) {
357 ALOGE("%s: edid_modes file empty", __FUNCTION__);
Arun Kumar K.R83812342013-09-24 17:30:36 -0700358 edidStr[0] = '\0';
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700359 }
360 else {
Arun Kumar K.R83812342013-09-24 17:30:36 -0700361 while (len > 1 && isspace(edidStr[len-1])) {
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700362 --len;
Arun Kumar K.R83812342013-09-24 17:30:36 -0700363 }
364 edidStr[len] = '\0';
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700365 }
Dileep Kumar Reddibf333c72014-02-25 14:32:51 +0530366 close(hdmiEDIDFile);
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700367 }
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700368 if(len > 0) {
Amara Venkata Mastan Manoj Kumar5182a782012-12-03 12:08:48 -0800369 // Get EDID modes from the EDID strings
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700370 mModeCount = parseResolution(edidStr);
Naseer Ahmed72cf9762012-07-21 12:17:13 -0700371 ALOGD_IF(DEBUG, "%s: mModeCount = %d", __FUNCTION__,
372 mModeCount);
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700373 }
374
Arun Kumar K.R83812342013-09-24 17:30:36 -0700375 return (len > 0);
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700376}
377
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -0700378bool HDMIDisplay::openFrameBuffer()
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700379{
Naseer Ahmedf8ec1622012-07-31 18:56:23 -0700380 if (mFd == -1) {
Jeykumar Sankaran27dee262013-08-01 17:09:54 -0700381 char strDevPath[MAX_SYSFS_FILE_PATH];
382 snprintf(strDevPath, MAX_SYSFS_FILE_PATH, "/dev/graphics/fb%d", mFbNum);
383 mFd = open(strDevPath, O_RDWR);
Naseer Ahmedf8ec1622012-07-31 18:56:23 -0700384 if (mFd < 0)
Jeykumar Sankaran27dee262013-08-01 17:09:54 -0700385 ALOGE("%s: %s is not available", __FUNCTION__, strDevPath);
Saurabh Shah3e858eb2012-09-17 16:53:21 -0700386 }
Naseer Ahmedf8ec1622012-07-31 18:56:23 -0700387 return (mFd > 0);
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700388}
389
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -0700390bool HDMIDisplay::closeFrameBuffer()
Naseer Ahmedf8ec1622012-07-31 18:56:23 -0700391{
392 int ret = 0;
Naseer Ahmedf53b3772013-02-15 19:13:50 -0500393 if(mFd >= 0) {
Naseer Ahmedf8ec1622012-07-31 18:56:23 -0700394 ret = close(mFd);
395 mFd = -1;
396 }
397 return (ret == 0);
398}
399
400// clears the vinfo, edid, best modes
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -0700401void HDMIDisplay::resetInfo()
Naseer Ahmedf8ec1622012-07-31 18:56:23 -0700402{
403 memset(&mVInfo, 0, sizeof(mVInfo));
Naseer Ahmedf8ec1622012-07-31 18:56:23 -0700404 memset(mEDIDModes, 0, sizeof(mEDIDModes));
405 mModeCount = 0;
406 mCurrentMode = -1;
Arun Kumar K.Rfeb2d8a2013-02-01 02:53:13 -0800407 mUnderscanSupported = false;
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700408 mXres = 0;
409 mYres = 0;
410 mVsyncPeriod = 0;
411 mMDPScalingMode = false;
Arun Kumar K.Rfeb2d8a2013-02-01 02:53:13 -0800412 // Reset the underscan supported system property
413 const char* prop = "0";
414 property_set("hw.underscan_supported", prop);
Naseer Ahmedf8ec1622012-07-31 18:56:23 -0700415}
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700416
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -0700417int HDMIDisplay::getModeOrder(int mode)
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700418{
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700419 for (int dataIndex = 0; dataIndex < gEDIDCount; dataIndex++) {
420 if (gEDIDData[dataIndex].mMode == mode) {
421 return gEDIDData[dataIndex].mModeOrder;
422 }
Naseer Ahmed72cf9762012-07-21 12:17:13 -0700423 }
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700424 ALOGE("%s Mode not found: %d", __FUNCTION__, mode);
425 return -1;
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700426}
427
Arun Kumar K.R37552c52012-12-10 12:47:18 -0800428/// Returns the user mode set(if any) using adb shell
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -0700429int HDMIDisplay::getUserMode() {
Arun Kumar K.R37552c52012-12-10 12:47:18 -0800430 /* Based on the property set the resolution */
431 char property_value[PROPERTY_VALUE_MAX];
Arun Kumar K.Rc31bdcb2013-02-25 17:47:42 -0800432 property_get("hw.hdmi.resolution", property_value, "-1");
Arun Kumar K.R37552c52012-12-10 12:47:18 -0800433 int mode = atoi(property_value);
434 // We dont support interlaced modes
435 if(isValidMode(mode) && !isInterlacedMode(mode)) {
Naseer Ahmed74214722013-02-09 08:11:36 -0500436 ALOGD_IF(DEBUG, "%s: setting the HDMI mode = %d", __FUNCTION__, mode);
Arun Kumar K.R37552c52012-12-10 12:47:18 -0800437 return mode;
438 }
439 return -1;
440}
441
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700442// Get the best mode for the current HD TV
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -0700443int HDMIDisplay::getBestMode() {
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700444 int bestOrder = 0;
Arun Kumar K.R25187572013-02-28 18:47:36 -0800445 int bestMode = HDMI_VFRMT_640x480p60_4_3;
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700446 // for all the edid read, get the best mode
447 for(int i = 0; i < mModeCount; i++) {
448 int mode = mEDIDModes[i];
449 int order = getModeOrder(mode);
450 if (order > bestOrder) {
451 bestOrder = order;
452 bestMode = mode;
453 }
454 }
455 return bestMode;
Naseer Ahmed72cf9762012-07-21 12:17:13 -0700456}
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700457
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -0700458inline bool HDMIDisplay::isValidMode(int ID)
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700459{
Arun Kumar K.R37552c52012-12-10 12:47:18 -0800460 bool valid = false;
461 for (int i = 0; i < mModeCount; i++) {
462 if(ID == mEDIDModes[i]) {
463 valid = true;
464 break;
465 }
466 }
467 return valid;
468}
469
470// returns true if the mode(ID) is interlaced mode format
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -0700471bool HDMIDisplay::isInterlacedMode(int ID) {
Arun Kumar K.R37552c52012-12-10 12:47:18 -0800472 bool interlaced = false;
473 switch(ID) {
Arun Kumar K.R25187572013-02-28 18:47:36 -0800474 case HDMI_VFRMT_1440x480i60_4_3:
475 case HDMI_VFRMT_1440x480i60_16_9:
476 case HDMI_VFRMT_1440x576i50_4_3:
477 case HDMI_VFRMT_1440x576i50_16_9:
478 case HDMI_VFRMT_1920x1080i60_16_9:
Arun Kumar K.R37552c52012-12-10 12:47:18 -0800479 interlaced = true;
Arun Kumar K.Rae46f3a2013-05-16 16:40:10 -0700480 break;
Arun Kumar K.R37552c52012-12-10 12:47:18 -0800481 default:
482 interlaced = false;
Arun Kumar K.Rae46f3a2013-05-16 16:40:10 -0700483 break;
Arun Kumar K.R37552c52012-12-10 12:47:18 -0800484 }
485 return interlaced;
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700486}
487
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700488// Does a put_vscreen info on the HDMI interface which will update
489// the configuration (resolution, timing info) to match mCurrentMode
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -0700490void HDMIDisplay::activateDisplay()
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700491{
Naseer Ahmedf8ec1622012-07-31 18:56:23 -0700492 int ret = 0;
Naseer Ahmedf8ec1622012-07-31 18:56:23 -0700493 ret = ioctl(mFd, FBIOGET_VSCREENINFO, &mVInfo);
494 if(ret < 0) {
495 ALOGD("In %s: FBIOGET_VSCREENINFO failed Err Str = %s", __FUNCTION__,
496 strerror(errno));
497 }
Naseer Ahmedf8ec1622012-07-31 18:56:23 -0700498 ALOGD_IF(DEBUG, "%s: GET Info<ID=%d %dx%d (%d,%d,%d),"
499 "(%d,%d,%d) %dMHz>", __FUNCTION__,
500 mVInfo.reserved[3], mVInfo.xres, mVInfo.yres,
501 mVInfo.right_margin, mVInfo.hsync_len, mVInfo.left_margin,
502 mVInfo.lower_margin, mVInfo.vsync_len, mVInfo.upper_margin,
503 mVInfo.pixclock/1000/1000);
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700504
505 const struct msm_hdmi_mode_timing_info *mode =
Naseer Ahmed72cf9762012-07-21 12:17:13 -0700506 &supported_video_mode_lut[0];
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700507 for (unsigned int i = 0; i < HDMI_VFRMT_MAX; ++i) {
508 const struct msm_hdmi_mode_timing_info *cur =
509 &supported_video_mode_lut[i];
510 if (cur->video_format == (uint32_t)mCurrentMode) {
511 mode = cur;
512 break;
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700513 }
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700514 }
515 setDisplayTiming(mVInfo, mode);
516 ALOGD_IF(DEBUG, "%s: SET Info<ID=%d => Info<ID=%d %dx %d"
517 "(%d,%d,%d), (%d,%d,%d) %dMHz>", __FUNCTION__, mCurrentMode,
518 mode->video_format, mVInfo.xres, mVInfo.yres,
519 mVInfo.right_margin, mVInfo.hsync_len, mVInfo.left_margin,
520 mVInfo.lower_margin, mVInfo.vsync_len, mVInfo.upper_margin,
521 mVInfo.pixclock/1000/1000);
Ken Zhang7b03a952013-01-16 13:23:48 -0500522#ifdef FB_METADATA_VIDEO_INFO_CODE_SUPPORT
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700523 struct msmfb_metadata metadata;
524 memset(&metadata, 0 , sizeof(metadata));
525 metadata.op = metadata_op_vic;
526 metadata.data.video_info_code = mode->video_format;
527 if (ioctl(mFd, MSMFB_METADATA_SET, &metadata) == -1) {
528 ALOGD("In %s: MSMFB_METADATA_SET failed Err Str = %s",
529 __FUNCTION__, strerror(errno));
530 }
Ken Zhang7b03a952013-01-16 13:23:48 -0500531#endif
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700532 mVInfo.activate = FB_ACTIVATE_NOW | FB_ACTIVATE_ALL | FB_ACTIVATE_FORCE;
533 ret = ioctl(mFd, FBIOPUT_VSCREENINFO, &mVInfo);
534 if(ret < 0) {
535 ALOGD("In %s: FBIOPUT_VSCREENINFO failed Err Str = %s",
536 __FUNCTION__, strerror(errno));
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700537 }
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700538}
539
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -0700540bool HDMIDisplay::writeHPDOption(int userOption) const
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700541{
542 bool ret = true;
Jeykumar Sankaran27dee262013-08-01 17:09:54 -0700543 if(mFbNum != -1) {
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700544 int hdmiHPDFile = openDeviceNode("hpd", O_RDWR);
545 if (hdmiHPDFile >= 0) {
Dileep Kumar Reddibf333c72014-02-25 14:32:51 +0530546 ssize_t err = -1;
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700547 ALOGD_IF(DEBUG, "%s: option = %d",
548 __FUNCTION__, userOption);
Arun Kumar K.R47d6b642013-06-26 16:20:30 -0700549 if(userOption)
550 err = write(hdmiHPDFile, "1", 2);
551 else
552 err = write(hdmiHPDFile, "0" , 2);
553 if (err <= 0) {
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700554 ALOGE("%s: file write failed 'hpd'", __FUNCTION__);
Arun Kumar K.R47d6b642013-06-26 16:20:30 -0700555 ret = false;
556 }
557 close(hdmiHPDFile);
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700558 }
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700559 }
560 return ret;
561}
Naseer Ahmedf8ec1622012-07-31 18:56:23 -0700562
Amara Venkata Mastan Manoj Kumar376d8a82013-03-13 19:18:47 -0700563
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -0700564void HDMIDisplay::setAttributes() {
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700565 uint32_t fps = 0;
566 // Always set dpyAttr res to mVInfo res
567 getAttrForMode(mXres, mYres, fps);
568 mMDPScalingMode = false;
569
570 if(overlay::Overlay::getInstance()->isUIScalingOnExternalSupported()
571 && mMDPDownscaleEnabled) {
572 // if primary resolution is more than the hdmi resolution
573 // configure dpy attr to primary resolution and set MDP
574 // scaling mode
575 // Restrict this upto 1080p resolution max, if target does not
576 // support source split feature.
577 uint32_t primaryArea = mPrimaryWidth * mPrimaryHeight;
578 if(((primaryArea) > (mXres * mYres)) &&
579 (((primaryArea) <= SUPPORTED_DOWNSCALE_AREA) ||
Ramkumar Radhakrishnana5c72872014-08-28 19:04:18 -0700580 qdutils::MDPVersion::getInstance().isSrcSplit())) {
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700581 // tmpW and tmpH will hold the primary dimensions before we
582 // update the aspect ratio if necessary.
583 int tmpW = mPrimaryWidth;
584 int tmpH = mPrimaryHeight;
585 // HDMI is always in landscape, so always assign the higher
586 // dimension to hdmi's xres
587 if(mPrimaryHeight > mPrimaryWidth) {
588 tmpW = mPrimaryHeight;
589 tmpH = mPrimaryWidth;
Amara Venkata Mastan Manoj Kumar376d8a82013-03-13 19:18:47 -0700590 }
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700591 // The aspect ratios of the external and primary displays
592 // can be different. As a result, directly assigning primary
593 // resolution could lead to an incorrect final image.
594 // We get around this by calculating a new resolution by
595 // keeping aspect ratio intact.
596 hwc_rect r = {0, 0, 0, 0};
597 qdutils::getAspectRatioPosition(tmpW, tmpH, mXres, mYres, r);
598 uint32_t newExtW = r.right - r.left;
599 uint32_t newExtH = r.bottom - r.top;
600 uint32_t alignedExtW;
601 uint32_t alignedExtH;
602 // On 8994 and below targets MDP supports only 4X downscaling,
603 // Restricting selected external resolution to be exactly 4X
604 // greater resolution than actual external resolution
605 uint32_t maxMDPDownScale =
606 qdutils::MDPVersion::getInstance().getMaxMDPDownscale();
607 if((mXres * mYres * maxMDPDownScale) < (newExtW * newExtH)) {
608 float upScaleFactor = (float)maxMDPDownScale / 2.0f;
609 newExtW = (int)((float)mXres * upScaleFactor);
610 newExtH = (int)((float)mYres * upScaleFactor);
611 }
612 // Align it down so that the new aligned resolution does not
613 // exceed the maxMDPDownscale factor
614 alignedExtW = overlay::utils::aligndown(newExtW, 4);
615 alignedExtH = overlay::utils::aligndown(newExtH, 4);
616 mXres = alignedExtW;
617 mYres = alignedExtH;
618 // Set External Display MDP Downscale mode indicator
619 mMDPScalingMode = true;
Amara Venkata Mastan Manoj Kumar376d8a82013-03-13 19:18:47 -0700620 }
Amara Venkata Mastan Manoj Kumar376d8a82013-03-13 19:18:47 -0700621 }
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700622 ALOGD_IF(DEBUG_MDPDOWNSCALE, "Selected external resolution [%d X %d] "
623 "maxMDPDownScale %d mMDPScalingMode %d srcSplitEnabled %d "
624 "MDPDownscale feature %d",
625 mXres, mYres,
626 qdutils::MDPVersion::getInstance().getMaxMDPDownscale(),
627 mMDPScalingMode, qdutils::MDPVersion::getInstance().isSrcSplit(),
628 mMDPDownscaleEnabled);
629 mVsyncPeriod = (int) 1000000000l / fps;
630 ALOGD_IF(DEBUG, "%s xres=%d, yres=%d", __FUNCTION__, mXres, mYres);
Saurabh Shah3e858eb2012-09-17 16:53:21 -0700631}
632
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -0700633void HDMIDisplay::getAttrForMode(uint32_t& width, uint32_t& height,
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700634 uint32_t& fps) {
635 for (int dataIndex = 0; dataIndex < gEDIDCount; dataIndex++) {
636 if (gEDIDData[dataIndex].mMode == mCurrentMode) {
637 width = gEDIDData[dataIndex].mWidth;
638 height = gEDIDData[dataIndex].mHeight;
639 fps = gEDIDData[dataIndex].mFps;
640 return;
641 }
Saurabh Shah3e858eb2012-09-17 16:53:21 -0700642 }
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700643 ALOGE("%s Unable to get attributes for %d", __FUNCTION__, mCurrentMode);
644}
645
646/* returns the fd related to the node specified*/
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -0700647int HDMIDisplay::openDeviceNode(const char* node, int fileMode) const {
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700648 char sysFsFilePath[MAX_SYSFS_FILE_PATH];
649 memset(sysFsFilePath, 0, sizeof(sysFsFilePath));
650 snprintf(sysFsFilePath , sizeof(sysFsFilePath),
651 "/sys/devices/virtual/graphics/fb%d/%s",
652 mFbNum, node);
653
654 int fd = open(sysFsFilePath, fileMode, 0);
655
656 if (fd < 0) {
657 ALOGE("%s: file '%s' not found : ret = %d err str: %s",
658 __FUNCTION__, sysFsFilePath, fd, strerror(errno));
659 }
660 return fd;
661}
662
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -0700663bool HDMIDisplay::isHDMIPrimaryDisplay() {
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700664 int hdmiNode = qdutils::getHDMINode();
665 return (hdmiNode == HWC_DISPLAY_PRIMARY);
666}
667
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -0700668int HDMIDisplay::getConnectedState() {
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700669 int ret = -1;
670 int mFbNum = qdutils::getHDMINode();
671 int connectedNode = openDeviceNode("connected", O_RDONLY);
672 if(connectedNode >= 0) {
673 char opStr[4];
674 ssize_t bytesRead = read(connectedNode, opStr, sizeof(opStr) - 1);
675 if(bytesRead > 0) {
676 opStr[bytesRead] = '\0';
677 ret = atoi(opStr);
678 ALOGD_IF(DEBUG, "%s: Read %d from connected", __FUNCTION__, ret);
679 } else if(bytesRead == 0) {
680 ALOGE("%s: HDMI connected node empty", __FUNCTION__);
681 } else {
682 ALOGE("%s: Read from HDMI connected node failed with error %s",
683 __FUNCTION__, strerror(errno));
684 }
685 close(connectedNode);
686 } else {
687 ALOGD("%s: /sys/class/graphics/fb%d/connected could not be opened : %s",
688 __FUNCTION__, mFbNum, strerror(errno));
689 }
690 return ret;
691}
692
Tatenda Chipeperekwaaf2c0042014-09-17 12:55:01 -0700693void HDMIDisplay::setPrimaryAttributes(uint32_t primaryWidth,
Tatenda Chipeperekwa03d5df22014-09-16 18:09:18 -0700694 uint32_t primaryHeight) {
695 mPrimaryHeight = primaryHeight;
696 mPrimaryWidth = primaryWidth;
Naseer Ahmedf8ec1622012-07-31 18:56:23 -0700697}
698
Naseer Ahmed0c8b7b52012-07-20 09:06:13 -0700699};