Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 3 | * Copyright (C) 2012, The Linux Foundation. All rights reserved. |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 4 | * |
| 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 Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 21 | #define DEBUG 0 |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 22 | #include <ctype.h> |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 23 | #include <fcntl.h> |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 24 | #include <media/IAudioPolicyService.h> |
| 25 | #include <media/AudioSystem.h> |
| 26 | #include <utils/threads.h> |
| 27 | #include <utils/Errors.h> |
| 28 | #include <utils/Log.h> |
| 29 | |
| 30 | #include <linux/msm_mdp.h> |
| 31 | #include <linux/fb.h> |
| 32 | #include <sys/ioctl.h> |
| 33 | #include <sys/poll.h> |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 34 | #include <sys/resource.h> |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 35 | #include <cutils/properties.h> |
| 36 | #include "hwc_utils.h" |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 37 | #include "external.h" |
| 38 | #include "overlayUtils.h" |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 39 | #include "overlay.h" |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 40 | |
| 41 | using namespace android; |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 42 | |
| 43 | namespace qhwc { |
| 44 | |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 45 | #define MAX_FRAME_BUFFER_NAME_SIZE (80) |
| 46 | #define MAX_DISPLAY_DEVICES (3) |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 47 | |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 48 | |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 49 | const char* msmFbDevicePath[] = { "/dev/graphics/fb1", |
| 50 | "/dev/graphics/fb2"}; |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 51 | |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 52 | /* |
| 53 | * Updates extDeviceFbIndex Array with the correct frame buffer indices |
| 54 | * of avaiable external devices |
| 55 | * |
| 56 | */ |
| 57 | void ExternalDisplay::updateExtDispDevFbIndex() |
| 58 | { |
| 59 | FILE *displayDeviceFP = NULL; |
| 60 | char fbType[MAX_FRAME_BUFFER_NAME_SIZE]; |
| 61 | char msmFbTypePath[MAX_FRAME_BUFFER_NAME_SIZE]; |
| 62 | |
| 63 | for(int j = 1; j < MAX_DISPLAY_DEVICES; j++) { |
| 64 | sprintf (msmFbTypePath,"/sys/class/graphics/fb%d/msm_fb_type", j); |
| 65 | displayDeviceFP = fopen(msmFbTypePath, "r"); |
| 66 | if(displayDeviceFP){ |
| 67 | fread(fbType, sizeof(char), MAX_FRAME_BUFFER_NAME_SIZE, |
| 68 | displayDeviceFP); |
| 69 | if(strncmp(fbType, "dtv panel", strlen("dtv panel")) == 0){ |
| 70 | ALOGD_IF(DEBUG,"hdmi framebuffer index is %d",j); |
| 71 | mHdmiFbNum = j; |
| 72 | } else if(strncmp(fbType, "writeback panel", |
| 73 | strlen("writeback panel")) == 0){ |
| 74 | ALOGD_IF(DEBUG,"wfd framebuffer index is %d",j); |
| 75 | mWfdFbNum = j; |
| 76 | } |
| 77 | fclose(displayDeviceFP); |
| 78 | } |
| 79 | } |
| 80 | ALOGD_IF(DEBUG,"%s: mHdmiFbNum: %d mWfdFbNum: %d ",__FUNCTION__, |
| 81 | mHdmiFbNum, mWfdFbNum); |
| 82 | } |
| 83 | |
| 84 | int ExternalDisplay::configureHDMIDisplay() { |
| 85 | openFrameBuffer(mHdmiFbNum); |
| 86 | if(mFd == -1) |
| 87 | return -1; |
| 88 | readResolution(); |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 89 | // TODO: Move this to activate |
Arun Kumar K.R | 37552c5 | 2012-12-10 12:47:18 -0800 | [diff] [blame] | 90 | /* Used for changing the resolution |
| 91 | * getUserMode will get the preferred |
| 92 | * mode set thru adb shell */ |
| 93 | int mode = getUserMode(); |
| 94 | if (mode == -1) { |
| 95 | //Get the best mode and set |
| 96 | mode = getBestMode(); |
| 97 | } |
| 98 | setResolution(mode); |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 99 | setDpyHdmiAttr(); |
| 100 | setExternalDisplay(true, mHdmiFbNum); |
| 101 | return 0; |
| 102 | } |
| 103 | |
| 104 | int ExternalDisplay::configureWFDDisplay() { |
| 105 | int ret = 0; |
| 106 | if(mConnectedFbNum == mHdmiFbNum) { |
| 107 | ALOGE("%s: Cannot process WFD connection while HDMI is active", |
| 108 | __FUNCTION__); |
| 109 | return -1; |
| 110 | } |
| 111 | openFrameBuffer(mWfdFbNum); |
| 112 | if(mFd == -1) |
| 113 | return -1; |
| 114 | ret = ioctl(mFd, FBIOGET_VSCREENINFO, &mVInfo); |
| 115 | if(ret < 0) { |
| 116 | ALOGD("In %s: FBIOGET_VSCREENINFO failed Err Str = %s", __FUNCTION__, |
| 117 | strerror(errno)); |
| 118 | } |
| 119 | setDpyWfdAttr(); |
| 120 | setExternalDisplay(true, mWfdFbNum); |
| 121 | return 0; |
| 122 | } |
| 123 | |
| 124 | int ExternalDisplay::teardownHDMIDisplay() { |
| 125 | if(mConnectedFbNum == mHdmiFbNum) { |
| 126 | // hdmi offline event..! |
| 127 | closeFrameBuffer(); |
| 128 | resetInfo(); |
| 129 | setExternalDisplay(false); |
| 130 | } |
| 131 | return 0; |
| 132 | } |
| 133 | |
| 134 | int ExternalDisplay::teardownWFDDisplay() { |
| 135 | if(mConnectedFbNum == mWfdFbNum) { |
| 136 | // wfd offline event..! |
| 137 | closeFrameBuffer(); |
| 138 | memset(&mVInfo, 0, sizeof(mVInfo)); |
| 139 | setExternalDisplay(false); |
| 140 | } |
| 141 | return 0; |
| 142 | } |
| 143 | |
| 144 | void ExternalDisplay::processUEventOnline(const char *str) { |
| 145 | const char *s1 = str + strlen("change@/devices/virtual/switch/"); |
| 146 | if(!strncmp(s1,"hdmi",strlen(s1))) { |
| 147 | // hdmi online event..! |
| 148 | configureHDMIDisplay(); |
Arun Kumar K.R | bfc79c2 | 2013-01-15 13:34:05 -0800 | [diff] [blame] | 149 | // set system property |
| 150 | property_set("hw.hdmiON", "1"); |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 151 | }else if(!strncmp(s1,"wfd",strlen(s1))) { |
| 152 | // wfd online event..! |
| 153 | configureWFDDisplay(); |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | void ExternalDisplay::processUEventOffline(const char *str) { |
| 158 | const char *s1 = str + strlen("change@/devices/virtual/switch/"); |
| 159 | if(!strncmp(s1,"hdmi",strlen(s1))) { |
| 160 | teardownHDMIDisplay(); |
Arun Kumar K.R | bfc79c2 | 2013-01-15 13:34:05 -0800 | [diff] [blame] | 161 | // unset system property |
| 162 | property_set("hw.hdmiON", "0"); |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 163 | }else if(!strncmp(s1,"wfd",strlen(s1))) { |
| 164 | teardownWFDDisplay(); |
| 165 | } |
| 166 | } |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 167 | |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 168 | ExternalDisplay::ExternalDisplay(hwc_context_t* ctx):mFd(-1), |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 169 | mCurrentMode(-1), mConnected(0), mConnectedFbNum(0), mModeCount(0), |
| 170 | mHwcContext(ctx), mHdmiFbNum(-1), mWfdFbNum(-1) |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 171 | { |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 172 | memset(&mVInfo, 0, sizeof(mVInfo)); |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 173 | //Determine the fb index for external display devices. |
| 174 | updateExtDispDevFbIndex(); |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 175 | } |
| 176 | |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 177 | void ExternalDisplay::setEDIDMode(int resMode) { |
| 178 | ALOGD_IF(DEBUG,"resMode=%d ", resMode); |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 179 | { |
| 180 | Mutex::Autolock lock(mExtDispLock); |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 181 | setExternalDisplay(false); |
| 182 | openFrameBuffer(mHdmiFbNum); |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 183 | setResolution(resMode); |
| 184 | } |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 185 | setExternalDisplay(true, mHdmiFbNum); |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 186 | } |
| 187 | |
| 188 | void ExternalDisplay::setHPD(uint32_t startEnd) { |
| 189 | ALOGD_IF(DEBUG,"HPD enabled=%d", startEnd); |
| 190 | writeHPDOption(startEnd); |
| 191 | } |
| 192 | |
| 193 | void ExternalDisplay::setActionSafeDimension(int w, int h) { |
| 194 | ALOGD_IF(DEBUG,"ActionSafe w=%d h=%d", w, h); |
| 195 | Mutex::Autolock lock(mExtDispLock); |
| 196 | overlay::utils::ActionSafe::getInstance()->setDimension(w, h); |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 197 | setExternalDisplay(true, mHdmiFbNum); |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | int ExternalDisplay::getModeCount() const { |
| 201 | ALOGD_IF(DEBUG,"HPD mModeCount=%d", mModeCount); |
| 202 | Mutex::Autolock lock(mExtDispLock); |
| 203 | return mModeCount; |
| 204 | } |
| 205 | |
| 206 | void ExternalDisplay::getEDIDModes(int *out) const { |
| 207 | Mutex::Autolock lock(mExtDispLock); |
| 208 | for(int i = 0;i < mModeCount;i++) { |
| 209 | out[i] = mEDIDModes[i]; |
| 210 | } |
| 211 | } |
| 212 | |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 213 | ExternalDisplay::~ExternalDisplay() |
| 214 | { |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 215 | closeFrameBuffer(); |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 216 | } |
| 217 | |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 218 | struct disp_mode_timing_type { |
| 219 | int video_format; |
| 220 | |
| 221 | int active_h; |
| 222 | int active_v; |
| 223 | |
| 224 | int front_porch_h; |
| 225 | int pulse_width_h; |
| 226 | int back_porch_h; |
| 227 | |
| 228 | int front_porch_v; |
| 229 | int pulse_width_v; |
| 230 | int back_porch_v; |
| 231 | |
| 232 | int pixel_freq; |
| 233 | bool interlaced; |
| 234 | |
| 235 | void set_info(struct fb_var_screeninfo &info) const; |
| 236 | }; |
| 237 | |
| 238 | void disp_mode_timing_type::set_info(struct fb_var_screeninfo &info) const |
| 239 | { |
| 240 | info.reserved[0] = 0; |
| 241 | info.reserved[1] = 0; |
| 242 | info.reserved[2] = 0; |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 243 | info.reserved[3] = (info.reserved[3] & 0xFFFF) | (video_format << 16); |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 244 | |
| 245 | info.xoffset = 0; |
| 246 | info.yoffset = 0; |
| 247 | info.xres = active_h; |
| 248 | info.yres = active_v; |
| 249 | |
| 250 | info.pixclock = pixel_freq*1000; |
| 251 | info.vmode = interlaced ? FB_VMODE_INTERLACED : FB_VMODE_NONINTERLACED; |
| 252 | |
| 253 | info.right_margin = front_porch_h; |
| 254 | info.hsync_len = pulse_width_h; |
| 255 | info.left_margin = back_porch_h; |
| 256 | info.lower_margin = front_porch_v; |
| 257 | info.vsync_len = pulse_width_v; |
| 258 | info.upper_margin = back_porch_v; |
| 259 | } |
| 260 | |
| 261 | /* Video formates supported by the HDMI Standard */ |
| 262 | /* Indicates the resolution, pix clock and the aspect ratio */ |
| 263 | #define m640x480p60_4_3 1 |
| 264 | #define m720x480p60_4_3 2 |
| 265 | #define m720x480p60_16_9 3 |
| 266 | #define m1280x720p60_16_9 4 |
| 267 | #define m1920x1080i60_16_9 5 |
| 268 | #define m1440x480i60_4_3 6 |
| 269 | #define m1440x480i60_16_9 7 |
| 270 | #define m1920x1080p60_16_9 16 |
| 271 | #define m720x576p50_4_3 17 |
| 272 | #define m720x576p50_16_9 18 |
| 273 | #define m1280x720p50_16_9 19 |
| 274 | #define m1440x576i50_4_3 21 |
| 275 | #define m1440x576i50_16_9 22 |
| 276 | #define m1920x1080p50_16_9 31 |
| 277 | #define m1920x1080p24_16_9 32 |
| 278 | #define m1920x1080p25_16_9 33 |
| 279 | #define m1920x1080p30_16_9 34 |
| 280 | |
| 281 | static struct disp_mode_timing_type supported_video_mode_lut[] = { |
| 282 | {m640x480p60_4_3, 640, 480, 16, 96, 48, 10, 2, 33, 25200, false}, |
| 283 | {m720x480p60_4_3, 720, 480, 16, 62, 60, 9, 6, 30, 27030, false}, |
| 284 | {m720x480p60_16_9, 720, 480, 16, 62, 60, 9, 6, 30, 27030, false}, |
| 285 | {m1280x720p60_16_9, 1280, 720, 110, 40, 220, 5, 5, 20, 74250, false}, |
| 286 | {m1920x1080i60_16_9, 1920, 540, 88, 44, 148, 2, 5, 5, 74250, false}, |
| 287 | {m1440x480i60_4_3, 1440, 240, 38, 124, 114, 4, 3, 15, 27000, true}, |
| 288 | {m1440x480i60_16_9, 1440, 240, 38, 124, 114, 4, 3, 15, 27000, true}, |
| 289 | {m1920x1080p60_16_9, 1920, 1080, 88, 44, 148, 4, 5, 36, 148500, false}, |
| 290 | {m720x576p50_4_3, 720, 576, 12, 64, 68, 5, 5, 39, 27000, false}, |
| 291 | {m720x576p50_16_9, 720, 576, 12, 64, 68, 5, 5, 39, 27000, false}, |
| 292 | {m1280x720p50_16_9, 1280, 720, 440, 40, 220, 5, 5, 20, 74250, false}, |
| 293 | {m1440x576i50_4_3, 1440, 288, 24, 126, 138, 2, 3, 19, 27000, true}, |
| 294 | {m1440x576i50_16_9, 1440, 288, 24, 126, 138, 2, 3, 19, 27000, true}, |
| 295 | {m1920x1080p50_16_9, 1920, 1080, 528, 44, 148, 4, 5, 36, 148500, false}, |
| 296 | {m1920x1080p24_16_9, 1920, 1080, 638, 44, 148, 4, 5, 36, 74250, false}, |
| 297 | {m1920x1080p25_16_9, 1920, 1080, 528, 44, 148, 4, 5, 36, 74250, false}, |
| 298 | {m1920x1080p30_16_9, 1920, 1080, 88, 44, 148, 4, 5, 36, 74250, false}, |
| 299 | }; |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 300 | |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 301 | int ExternalDisplay::parseResolution(char* edidStr, int* edidModes) |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 302 | { |
| 303 | char delim = ','; |
| 304 | int count = 0; |
| 305 | char *start, *end; |
| 306 | // EDIDs are string delimited by ',' |
| 307 | // Ex: 16,4,5,3,32,34,1 |
| 308 | // Parse this string to get mode(int) |
| 309 | start = (char*) edidStr; |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 310 | end = &delim; |
| 311 | while(*end == delim) { |
| 312 | edidModes[count] = (int) strtol(start, &end, 10); |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 313 | start = end+1; |
| 314 | count++; |
| 315 | } |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 316 | ALOGD_IF(DEBUG, "In %s: count = %d", __FUNCTION__, count); |
| 317 | for (int i = 0; i < count; i++) |
| 318 | ALOGD_IF(DEBUG, "Mode[%d] = %d", i, edidModes[i]); |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 319 | return count; |
| 320 | } |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 321 | |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 322 | bool ExternalDisplay::readResolution() |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 323 | { |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 324 | char sysFsEDIDFilePath[255]; |
| 325 | sprintf(sysFsEDIDFilePath , "/sys/devices/virtual/graphics/fb%d/edid_modes", |
| 326 | mHdmiFbNum); |
| 327 | |
| 328 | int hdmiEDIDFile = open(sysFsEDIDFilePath, O_RDONLY, 0); |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 329 | int len = -1; |
| 330 | |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 331 | if (hdmiEDIDFile < 0) { |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 332 | ALOGE("%s: edid_modes file '%s' not found", |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 333 | __FUNCTION__, sysFsEDIDFilePath); |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 334 | return false; |
| 335 | } else { |
| 336 | len = read(hdmiEDIDFile, mEDIDs, sizeof(mEDIDs)-1); |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 337 | ALOGD_IF(DEBUG, "%s: EDID string: %s length = %d", |
| 338 | __FUNCTION__, mEDIDs, len); |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 339 | if ( len <= 0) { |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 340 | ALOGE("%s: edid_modes file empty '%s'", |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 341 | __FUNCTION__, sysFsEDIDFilePath); |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 342 | } |
| 343 | else { |
| 344 | while (len > 1 && isspace(mEDIDs[len-1])) |
| 345 | --len; |
| 346 | mEDIDs[len] = 0; |
| 347 | } |
| 348 | } |
| 349 | close(hdmiEDIDFile); |
| 350 | if(len > 0) { |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 351 | // Get EDID modes from the EDID strings |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 352 | mModeCount = parseResolution(mEDIDs, mEDIDModes); |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 353 | ALOGD_IF(DEBUG, "%s: mModeCount = %d", __FUNCTION__, |
| 354 | mModeCount); |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 355 | } |
| 356 | |
| 357 | return (strlen(mEDIDs) > 0); |
| 358 | } |
| 359 | |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 360 | bool ExternalDisplay::openFrameBuffer(int fbNum) |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 361 | { |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 362 | if (mFd == -1) { |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 363 | mFd = open(msmFbDevicePath[fbNum-1], O_RDWR); |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 364 | if (mFd < 0) |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 365 | ALOGE("%s: %s is not available", __FUNCTION__, |
| 366 | msmFbDevicePath[fbNum-1]); |
| 367 | if(mHwcContext) { |
| 368 | mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].fd = mFd; |
| 369 | } |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 370 | } |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 371 | return (mFd > 0); |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 372 | } |
| 373 | |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 374 | bool ExternalDisplay::closeFrameBuffer() |
| 375 | { |
| 376 | int ret = 0; |
| 377 | if(mFd > 0) { |
| 378 | ret = close(mFd); |
| 379 | mFd = -1; |
| 380 | } |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 381 | if(mHwcContext) { |
| 382 | mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].fd = mFd; |
| 383 | } |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 384 | return (ret == 0); |
| 385 | } |
| 386 | |
| 387 | // clears the vinfo, edid, best modes |
| 388 | void ExternalDisplay::resetInfo() |
| 389 | { |
| 390 | memset(&mVInfo, 0, sizeof(mVInfo)); |
| 391 | memset(mEDIDs, 0, sizeof(mEDIDs)); |
| 392 | memset(mEDIDModes, 0, sizeof(mEDIDModes)); |
| 393 | mModeCount = 0; |
| 394 | mCurrentMode = -1; |
| 395 | } |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 396 | |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 397 | int ExternalDisplay::getModeOrder(int mode) |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 398 | { |
Arun Kumar K.R | 37552c5 | 2012-12-10 12:47:18 -0800 | [diff] [blame] | 399 | // XXX: We dont support interlaced modes but having |
| 400 | // it here for for future |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 401 | switch (mode) { |
| 402 | default: |
| 403 | case m1440x480i60_4_3: |
| 404 | return 1; // 480i 4:3 |
| 405 | case m1440x480i60_16_9: |
| 406 | return 2; // 480i 16:9 |
| 407 | case m1440x576i50_4_3: |
| 408 | return 3; // i576i 4:3 |
| 409 | case m1440x576i50_16_9: |
| 410 | return 4; // 576i 16:9 |
| 411 | case m640x480p60_4_3: |
| 412 | return 5; // 640x480 4:3 |
| 413 | case m720x480p60_4_3: |
| 414 | return 6; // 480p 4:3 |
| 415 | case m720x480p60_16_9: |
| 416 | return 7; // 480p 16:9 |
| 417 | case m720x576p50_4_3: |
| 418 | return 8; // 576p 4:3 |
| 419 | case m720x576p50_16_9: |
| 420 | return 9; // 576p 16:9 |
| 421 | case m1920x1080i60_16_9: |
| 422 | return 10; // 1080i 16:9 |
| 423 | case m1280x720p50_16_9: |
| 424 | return 11; // 720p@50Hz |
| 425 | case m1280x720p60_16_9: |
| 426 | return 12; // 720p@60Hz |
| 427 | case m1920x1080p24_16_9: |
| 428 | return 13; //1080p@24Hz |
| 429 | case m1920x1080p25_16_9: |
| 430 | return 14; //108-p@25Hz |
| 431 | case m1920x1080p30_16_9: |
| 432 | return 15; //1080p@30Hz |
| 433 | case m1920x1080p50_16_9: |
| 434 | return 16; //1080p@50Hz |
| 435 | case m1920x1080p60_16_9: |
| 436 | return 17; //1080p@60Hz |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 437 | } |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 438 | } |
| 439 | |
Arun Kumar K.R | 37552c5 | 2012-12-10 12:47:18 -0800 | [diff] [blame] | 440 | /// Returns the user mode set(if any) using adb shell |
| 441 | int ExternalDisplay::getUserMode() { |
| 442 | /* Based on the property set the resolution */ |
| 443 | char property_value[PROPERTY_VALUE_MAX]; |
| 444 | property_get("hdmi.resolution", property_value, "-1"); |
| 445 | int mode = atoi(property_value); |
| 446 | // We dont support interlaced modes |
| 447 | if(isValidMode(mode) && !isInterlacedMode(mode)) { |
| 448 | ALOGD_IF("%s: setting the HDMI mode = %d", __FUNCTION__, mode); |
| 449 | return mode; |
| 450 | } |
| 451 | return -1; |
| 452 | } |
| 453 | |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 454 | // Get the best mode for the current HD TV |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 455 | int ExternalDisplay::getBestMode() { |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 456 | int bestOrder = 0; |
| 457 | int bestMode = m640x480p60_4_3; |
Saurabh Shah | 56f610d | 2012-08-07 15:27:06 -0700 | [diff] [blame] | 458 | Mutex::Autolock lock(mExtDispLock); |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 459 | // for all the edid read, get the best mode |
| 460 | for(int i = 0; i < mModeCount; i++) { |
| 461 | int mode = mEDIDModes[i]; |
| 462 | int order = getModeOrder(mode); |
| 463 | if (order > bestOrder) { |
| 464 | bestOrder = order; |
| 465 | bestMode = mode; |
| 466 | } |
| 467 | } |
| 468 | return bestMode; |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 469 | } |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 470 | |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 471 | inline bool ExternalDisplay::isValidMode(int ID) |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 472 | { |
Arun Kumar K.R | 37552c5 | 2012-12-10 12:47:18 -0800 | [diff] [blame] | 473 | bool valid = false; |
| 474 | for (int i = 0; i < mModeCount; i++) { |
| 475 | if(ID == mEDIDModes[i]) { |
| 476 | valid = true; |
| 477 | break; |
| 478 | } |
| 479 | } |
| 480 | return valid; |
| 481 | } |
| 482 | |
| 483 | // returns true if the mode(ID) is interlaced mode format |
| 484 | bool ExternalDisplay::isInterlacedMode(int ID) { |
| 485 | bool interlaced = false; |
| 486 | switch(ID) { |
| 487 | case m1440x480i60_4_3: |
| 488 | case m1440x480i60_16_9: |
| 489 | case m1440x576i50_4_3: |
| 490 | case m1440x576i50_16_9: |
| 491 | case m1920x1080i60_16_9: |
| 492 | interlaced = true; |
| 493 | default: |
| 494 | interlaced = false; |
| 495 | } |
| 496 | return interlaced; |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 497 | } |
| 498 | |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 499 | void ExternalDisplay::setResolution(int ID) |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 500 | { |
| 501 | struct fb_var_screeninfo info; |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 502 | int ret = 0; |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 503 | ret = ioctl(mFd, FBIOGET_VSCREENINFO, &mVInfo); |
| 504 | if(ret < 0) { |
| 505 | ALOGD("In %s: FBIOGET_VSCREENINFO failed Err Str = %s", __FUNCTION__, |
| 506 | strerror(errno)); |
| 507 | } |
| 508 | |
| 509 | ALOGD_IF(DEBUG, "%s: GET Info<ID=%d %dx%d (%d,%d,%d)," |
| 510 | "(%d,%d,%d) %dMHz>", __FUNCTION__, |
| 511 | mVInfo.reserved[3], mVInfo.xres, mVInfo.yres, |
| 512 | mVInfo.right_margin, mVInfo.hsync_len, mVInfo.left_margin, |
| 513 | mVInfo.lower_margin, mVInfo.vsync_len, mVInfo.upper_margin, |
| 514 | mVInfo.pixclock/1000/1000); |
Arun Kumar K.R | 37552c5 | 2012-12-10 12:47:18 -0800 | [diff] [blame] | 515 | //If its a new ID - update var_screeninfo |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 516 | if ((isValidMode(ID)) && mCurrentMode != ID) { |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 517 | const struct disp_mode_timing_type *mode = |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 518 | &supported_video_mode_lut[0]; |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 519 | unsigned count = sizeof(supported_video_mode_lut)/sizeof |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 520 | (*supported_video_mode_lut); |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 521 | for (unsigned int i = 0; i < count; ++i) { |
| 522 | const struct disp_mode_timing_type *cur = |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 523 | &supported_video_mode_lut[i]; |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 524 | if (cur->video_format == ID) |
| 525 | mode = cur; |
| 526 | } |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 527 | mode->set_info(mVInfo); |
| 528 | ALOGD_IF(DEBUG, "%s: SET Info<ID=%d => Info<ID=%d %dx %d" |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 529 | "(%d,%d,%d), (%d,%d,%d) %dMHz>", __FUNCTION__, ID, |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 530 | mVInfo.reserved[3], mVInfo.xres, mVInfo.yres, |
| 531 | mVInfo.right_margin, mVInfo.hsync_len, mVInfo.left_margin, |
| 532 | mVInfo.lower_margin, mVInfo.vsync_len, mVInfo.upper_margin, |
| 533 | mVInfo.pixclock/1000/1000); |
| 534 | mVInfo.activate = FB_ACTIVATE_NOW | FB_ACTIVATE_ALL | FB_ACTIVATE_FORCE; |
| 535 | ret = ioctl(mFd, FBIOPUT_VSCREENINFO, &mVInfo); |
| 536 | if(ret < 0) { |
| 537 | ALOGD("In %s: FBIOPUT_VSCREENINFO failed Err Str = %s", |
| 538 | __FUNCTION__, strerror(errno)); |
| 539 | } |
| 540 | mCurrentMode = ID; |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 541 | } |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 542 | } |
| 543 | |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 544 | void ExternalDisplay::setExternalDisplay(bool connected, int extFbNum) |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 545 | { |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 546 | hwc_context_t* ctx = mHwcContext; |
| 547 | if(ctx) { |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 548 | ALOGD_IF(DEBUG, "%s: connected = %d", __FUNCTION__, connected); |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 549 | // Store the external display |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 550 | mConnected = connected; |
| 551 | mConnectedFbNum = extFbNum; |
| 552 | mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].connected = connected; |
| 553 | // Update external fb number in Overlay context |
| 554 | overlay::Overlay::getInstance()->setExtFbNum(extFbNum); |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 555 | } |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 556 | } |
| 557 | |
| 558 | int ExternalDisplay::getExtFbNum(int &fbNum) { |
| 559 | int ret = -1; |
| 560 | if(mConnected) { |
| 561 | fbNum = mConnectedFbNum; |
| 562 | ret = 0; |
| 563 | } |
| 564 | return ret; |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 565 | } |
| 566 | |
Naseer Ahmed | 72cf976 | 2012-07-21 12:17:13 -0700 | [diff] [blame] | 567 | bool ExternalDisplay::writeHPDOption(int userOption) const |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 568 | { |
| 569 | bool ret = true; |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 570 | char sysFsHPDFilePath[255]; |
| 571 | sprintf(sysFsHPDFilePath ,"/sys/devices/virtual/graphics/fb%d/hpd", |
| 572 | mHdmiFbNum); |
| 573 | int hdmiHPDFile = open(sysFsHPDFilePath,O_RDWR, 0); |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 574 | if (hdmiHPDFile < 0) { |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 575 | ALOGE("%s: state file '%s' not found : ret%d err str: %s", __FUNCTION__, |
| 576 | sysFsHPDFilePath, hdmiHPDFile, strerror(errno)); |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 577 | ret = false; |
| 578 | } else { |
| 579 | int err = -1; |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 580 | ALOGD_IF(DEBUG, "%s: option = %d", __FUNCTION__, userOption); |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 581 | if(userOption) |
| 582 | err = write(hdmiHPDFile, "1", 2); |
| 583 | else |
| 584 | err = write(hdmiHPDFile, "0" , 2); |
| 585 | if (err <= 0) { |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 586 | ALOGE("%s: file write failed '%s'", __FUNCTION__, sysFsHPDFilePath); |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 587 | ret = false; |
| 588 | } |
| 589 | close(hdmiHPDFile); |
| 590 | } |
| 591 | return ret; |
| 592 | } |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 593 | |
Saurabh Shah | 3825f25 | 2012-09-21 16:32:18 -0700 | [diff] [blame] | 594 | /* |
| 595 | * commits the changes to the external display |
Saurabh Shah | 3825f25 | 2012-09-21 16:32:18 -0700 | [diff] [blame] | 596 | */ |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 597 | bool ExternalDisplay::post() |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 598 | { |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 599 | if(mFd == -1) |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 600 | return false; |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 601 | struct mdp_display_commit ext_commit; |
Naseer Ahmed | 9da8466 | 2012-12-06 19:29:29 -0500 | [diff] [blame] | 602 | memset(&ext_commit, 0, sizeof(struct mdp_display_commit)); |
| 603 | ext_commit.flags = MDP_DISPLAY_COMMIT_OVERLAY; |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 604 | if (ioctl(mFd, MSMFB_DISPLAY_COMMIT, &ext_commit) == -1) { |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 605 | ALOGE("%s: MSMFB_DISPLAY_COMMIT for external failed, str: %s", |
| 606 | __FUNCTION__, strerror(errno)); |
| 607 | return false; |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 608 | } |
| 609 | return true; |
| 610 | } |
| 611 | |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 612 | void ExternalDisplay::setDpyWfdAttr() { |
| 613 | if(mHwcContext) { |
| 614 | mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].xres = mVInfo.xres; |
| 615 | mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].yres = mVInfo.yres; |
| 616 | mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].vsync_period = |
| 617 | 1000000000l /60; |
| 618 | ALOGD_IF(DEBUG,"%s: wfd...connected..!",__FUNCTION__); |
| 619 | } |
| 620 | } |
| 621 | |
| 622 | void ExternalDisplay::setDpyHdmiAttr() { |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 623 | int width = 0, height = 0, fps = 0; |
| 624 | getAttrForMode(width, height, fps); |
| 625 | if(mHwcContext) { |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 626 | ALOGD("ExtDisplay setting xres = %d, yres = %d", width, height); |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 627 | mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].xres = width; |
| 628 | mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].yres = height; |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 629 | mHwcContext->dpyAttr[HWC_DISPLAY_EXTERNAL].vsync_period = |
| 630 | 1000000000l / fps; |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 631 | } |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 632 | } |
| 633 | |
Amara Venkata Mastan Manoj Kumar | 5182a78 | 2012-12-03 12:08:48 -0800 | [diff] [blame] | 634 | void ExternalDisplay::getAttrForMode(int& width, int& height, int& fps) { |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 635 | switch (mCurrentMode) { |
| 636 | case m640x480p60_4_3: |
| 637 | width = 640; |
| 638 | height = 480; |
| 639 | fps = 60; |
| 640 | break; |
| 641 | case m720x480p60_4_3: |
| 642 | case m720x480p60_16_9: |
| 643 | width = 720; |
| 644 | height = 480; |
| 645 | fps = 60; |
| 646 | break; |
| 647 | case m720x576p50_4_3: |
| 648 | case m720x576p50_16_9: |
| 649 | width = 720; |
| 650 | height = 576; |
| 651 | fps = 50; |
| 652 | break; |
| 653 | case m1280x720p50_16_9: |
| 654 | width = 1280; |
| 655 | height = 720; |
| 656 | fps = 50; |
| 657 | break; |
| 658 | case m1280x720p60_16_9: |
| 659 | width = 1280; |
| 660 | height = 720; |
| 661 | fps = 60; |
| 662 | break; |
| 663 | case m1920x1080p24_16_9: |
| 664 | width = 1920; |
| 665 | height = 1080; |
| 666 | fps = 24; |
| 667 | break; |
| 668 | case m1920x1080p25_16_9: |
| 669 | width = 1920; |
| 670 | height = 1080; |
| 671 | fps = 25; |
| 672 | break; |
| 673 | case m1920x1080p30_16_9: |
| 674 | width = 1920; |
| 675 | height = 1080; |
| 676 | fps = 30; |
| 677 | break; |
| 678 | case m1920x1080p50_16_9: |
| 679 | width = 1920; |
| 680 | height = 1080; |
| 681 | fps = 50; |
| 682 | break; |
| 683 | case m1920x1080p60_16_9: |
| 684 | width = 1920; |
| 685 | height = 1080; |
| 686 | fps = 60; |
| 687 | break; |
| 688 | } |
Naseer Ahmed | f8ec162 | 2012-07-31 18:56:23 -0700 | [diff] [blame] | 689 | } |
| 690 | |
Naseer Ahmed | 0c8b7b5 | 2012-07-20 09:06:13 -0700 | [diff] [blame] | 691 | }; |