Skip to content

Commit

Permalink
hwc: changes for hdmi hotplug and hpd
Browse files Browse the repository at this point in the history
This commit has the following changes:
1. Use hdmi switch node for hdmi hotplug
   - uses /devices/virtual/switch/hdmi switch_state to determine
     the hdmi connect/disconnect
   - this switch will be set to 1 on connect and 0 on disconnect
   - on connect, open framebuffer device, will trigger the hdcp
     authentication.
   - the driver will set the hdmi_audio switch to indicate that
     the HDMI sink supports audio
2. Enable HDP on unblank
   - this will resolve the device freeze during the bootup with hdmi
     connected

Change-Id: Id7a656d548a31178e31dcb9aea8acf38a56c9e0c
(cherry picked from commit 953b04b3cbba2f91d25795e5b0560c13d47844b0)
  • Loading branch information
Arun Kumar K.R authored and Sudhir Sharma committed Dec 6, 2012
1 parent 74d978a commit f6f49a1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 29 deletions.
2 changes: 0 additions & 2 deletions libexternal/external.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ ExternalDisplay::ExternalDisplay(hwc_context_t* ctx):mFd(-1),
mCurrentMode(-1), mExternalDisplay(0), mModeCount(0), mHwcContext(ctx)
{
memset(&mVInfo, 0, sizeof(mVInfo));
//Enable HPD for HDMI
writeHPDOption(1);
}

void ExternalDisplay::setEDIDMode(int resMode) {
Expand Down
3 changes: 3 additions & 0 deletions libhwcomposer/hwc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ static int hwc_blank(struct hwc_composer_device_1* dev, int dpy, int blank)
default:
return -EINVAL;
}
// Enable HPD here, as during bootup unblank is called
// when SF is completely initialized
ctx->mExtDisplay->setHPD(1);

if(ret < 0) {
ALOGE("%s: failed. Dpy=%d, blank=%d : %s",
Expand Down
48 changes: 21 additions & 27 deletions libhwcomposer/hwc_uevents.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

/*
* Copyright (C) 2010 The Android Open Source Project
* Copyright (C) 2012, The Linux Foundation. All rights reserved.
Expand Down Expand Up @@ -31,46 +32,39 @@ namespace qhwc {

#define HWC_UEVENT_THREAD_NAME "hwcUeventThread"

const char* MSMFB_HDMI_NODE = "fb1";

static void handle_uevent(hwc_context_t* ctx, const char* udata, int len)
{
int vsync = 0;
char* hdmi;
int64_t timestamp = 0;
const char *str = udata;

if(!strcasestr(str, "@/devices/virtual/graphics/fb")) {
if(!strcasestr(str, "change@/devices/virtual/switch/hdmi")) {
ALOGD_IF(UEVENT_DEBUG, "%s: Not Ext Disp Event ", __FUNCTION__);
return;
}
hdmi = strcasestr(str, MSMFB_HDMI_NODE);
// parse HDMI events
int connected = -1; // initial value - will be set to 1/0 based on hotplug
// parse HDMI switch state for connect/disconnect
// The event will be of the form:
// change@/devices/virtual/graphics/fb1 ACTION=change
// DEVPATH=/devices/virtual/graphics/fb1
// SUBSYSTEM=graphics HDCP_STATE=FAIL MAJOR=29
// for now just parsing onlin/offline info is enough
if (hdmi) {
str = udata;
int connected = -1; //some event other than online and offline .. e.g
if(!(strncmp(str,"online@",strlen("online@")))) {
//Disabled until SF calls unblank
ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].isActive = false;
connected = 1;
} else if(!(strncmp(str,"offline@",strlen("offline@")))) {
// change@/devices/virtual/switch/hdmi ACTION=change
// SWITCH_STATE=1 or SWITCH_STATE=0
while(*str) {
if (!strncmp(str, "SWITCH_STATE=", strlen("SWITCH_STATE="))) {
connected = atoi(str + strlen("SWITCH_STATE="));
//Disabled until SF calls unblank
ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].isActive = false;
connected = 0;
}
if(connected != -1) { //either we got online or offline
ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].connected = connected;
ctx->mExtDisplay->setExternalDisplay(connected);
ALOGD("%s sending hotplug: connected = %d", __FUNCTION__,connected);
Locker::Autolock _l(ctx->mExtSetLock); //hwc comp could be on
//TODO ideally should be done on "connected" not "online"
ctx->proc->hotplug(ctx->proc, HWC_DISPLAY_EXTERNAL, connected);
break;
}
str += strlen(str) + 1;
if (str - udata >= len)
break;
}

if(connected != -1) { //either we got switch_state connected or disconnect
ctx->dpyAttr[HWC_DISPLAY_EXTERNAL].connected = connected;
ctx->mExtDisplay->setExternalDisplay(connected);
ALOGD("%s sending hotplug: connected = %d", __FUNCTION__,connected);
Locker::Autolock _l(ctx->mExtSetLock); //hwc comp could be on
ctx->proc->hotplug(ctx->proc, HWC_DISPLAY_EXTERNAL, connected);
}
}

Expand Down

0 comments on commit f6f49a1

Please sign in to comment.