From 7fa6f9930189cab44579441260f91376c6a50ad1 Mon Sep 17 00:00:00 2001 From: Annamalai Lakshmanan Date: Fri, 18 May 2012 15:11:56 +0530 Subject: origen: added HDMI support Change-Id: Ia0c7b8c29027fc45182cf389e04130dbc15bb6b6 Signed-off-by: Annamalai Lakshmanan --- services/surfaceflinger/Android.mk | 9 ++ services/surfaceflinger/SurfaceFlinger.cpp | 155 ++++++++++++++++++++++++++++- 2 files changed, 163 insertions(+), 1 deletion(-) diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk index 7a7a57936794..985eb4804d16 100644 --- a/services/surfaceflinger/Android.mk +++ b/services/surfaceflinger/Android.mk @@ -35,6 +35,9 @@ ifeq ($(TARGET_BOARD_PLATFORM), s5pc110) LOCAL_CFLAGS += -DREFRESH_RATE=56 endif +ifeq ($(BOARD_HAVE_HDMI_SUPPORT),SAMSUNG_HDMI_SUPPORT) + LOCAL_CFLAGS += -DSAMSUNG_HDMI_SUPPORT +endif LOCAL_SHARED_LIBRARIES := \ libcutils \ @@ -54,6 +57,12 @@ LOCAL_C_INCLUDES := \ LOCAL_C_INCLUDES += hardware/libhardware/modules/gralloc +ifeq ($(BOARD_HAVE_HDMI_SUPPORT),SAMSUNG_HDMI_SUPPORT) + LOCAL_C_INCLUDES += vendor/samsung/origen/proprietary/include + LOCAL_LDFLAGS += vendor/samsung/origen/proprietary/system/lib/libfimc.so + LOCAL_LDFLAGS += vendor/samsung/origen/proprietary/system/lib/libhdmi.so +endif + LOCAL_MODULE:= libsurfaceflinger include $(BUILD_SHARED_LIBRARY) diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 0da75c4cacc6..192d257b294c 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -57,6 +57,9 @@ #include "DisplayHardware/HWComposer.h" #include +#ifdef SAMSUNG_HDMI_SUPPORT +#include "SecHdmi.h" +#endif /* ideally AID_GRAPHICS would be in a semi-public header * or there would be a way to map a user/group name to its id @@ -131,6 +134,12 @@ void SurfaceFlinger::init() SurfaceFlinger::~SurfaceFlinger() { glDeleteTextures(1, &mWormholeTexName); +#ifdef SAMSUNG_HDMI_SUPPORT + if(SecHdmi_destroy() == false) + { + LOGE("%s::mSecHdmi.destroy() fail \n", __func__); + } +#endif } sp SurfaceFlinger::getCblk() const @@ -295,6 +304,16 @@ status_t SurfaceFlinger::readyToRun() // put the origin in the left-bottom corner glOrthof(0, w, 0, h, 0, 1); // l=0, r=w ; b=0, t=h +#ifdef SAMSUNG_HDMI_SUPPORT + SecHdmi(); + if(SecHdmi_create() == 0) + LOGE("%s::mSecHdmi.create() fail \n", __func__); + else + { + // for it to connect + setHdmiStatus(1); + } +#endif mReadyToRunBarrier.open(); /* @@ -398,7 +417,10 @@ status_t SurfaceFlinger::postMessageSync(const sp& msg, bool SurfaceFlinger::threadLoop() { waitForEvent(); - +#ifdef SAMSUNG_HDMI_SUPPORT + //Check For HDMI Detection + setHdmiStatus(true); +#endif // check for transactions if (UNLIKELY(mConsoleSignals)) { handleConsoleEvents(); @@ -462,6 +484,12 @@ void SurfaceFlinger::postFramebuffer() mLastSwapBufferTime = systemTime() - now; mDebugInSwapBuffers = 0; mSwapRegion.clear(); +#ifdef SAMSUNG_HDMI_SUPPORT + if(mHdmiCableInserted) { + blit2Hdmi(hw.getWidth(), hw.getHeight(), 0, HDMI_MODE_UI, 0, 0); + } +#endif + } void SurfaceFlinger::handleConsoleEvents() @@ -1269,7 +1297,132 @@ int SurfaceFlinger::setOrientation(DisplayID dpy, } return orientation; } +#ifdef SAMSUNG_HDMI_SUPPORT +void setHdmiStatus(uint32_t status) +{ + + bool hdmiCableInserted = (bool)status; + + if(mHdmiCableInserted == hdmiCableInserted) + return; + + if(hdmiCableInserted == true) + { + if(SecHdmi_connect() == 0) + { + hdmiCableInserted = false; + } + } + else // if(hdmiCableInserted == false) + { + if(SecHdmi_disconnect() == 0) + { + LOGE("%s::mSecHdmi.disconnect() fail\n", __func__); + } + } + + mHdmiCableInserted = hdmiCableInserted; +} +void setHdmiMode(uint32_t mode) +{ +} +void setHdmiResolution(uint32_t resolution) +{ +} +void setHdmiHdcp(uint32_t hdcp_en) +{ +} +bool blit2Hdmi(int w, int h, + int colorFormat, + int hdmiMode, + unsigned int pPhyYAddr, unsigned int pPhyCAddr) +{ + //LOGD("%s HDMI layer buffer mNumberOfLayerBuffer: %d, flagOn = %d, colorFormat = %d", + // __func__, (unsigned int)mNumberOfLayerBuffer, flagOn, colorFormat); + + //Mutex::Autolock _l(mStateLock); + if(mHdmiCableInserted == false) + { + LOGE("mHdmiCableInserted == false fail"); + return false; + } + + mUIMode = hdmiMode; + + int hdmiLayer = HDMI_LAYER_VIDEO; + + switch(hdmiMode) + { + case HDMI_MODE_UI : + { + // kcoolsw + //LOGD("HDMI UI layer..."); + + /////////////////////////////////////////////// + // sw5771.park(100908) + // if NumOfLayer is = 0 + // draw with video layer (high quality) + // else NumOfLayer is 1, 2, 3 + // draw with graphic layer (low quality) + if(mNumberOfLayerBuffer == 1) + { + #ifdef BOARD_USES_HDMI_SUBTITLES + hdmiLayer = HDMI_LAYER_GRAPHIC_0; + #else + return true; + #endif + } + else // if(mNumberOfLayerBuffer == 0, 2, 3..) + { + #ifdef BOARD_USES_HDMI_SUBTITLES + { + // we change from LayerGraphics to LayerVideo for UI.. + if( mUILayerMode == HDMI_LAYER_GRAPHIC_0 + && hdmiLayer == HDMI_LAYER_VIDEO) + { + if(mSecHdmi.clear(mUILayerMode) == false) + { + LOGE("%s::mSecHdmi.clear(%d) fail\n", __func__, mUILayerMode); + } + } + } + #endif + } + + #ifdef BOARD_USES_HDMI_SUBTITLES + mUILayerMode = hdmiLayer; + #endif + + break; + } + case HDMI_MODE_VIDEO : + { + //LOGD("HDMI Video layer.."); + + // expect UI send video layer also.. + if(2 <= mNumberOfLayerBuffer) + return true; + + break; + } + default: + { + LOGE("unmatched HDMI_MODE : %d", hdmiMode); + return false; + break; + } + } + + if(SecHdmi_flush(w, h, colorFormat, hdmiLayer, + pPhyYAddr, pPhyCAddr) == false) + { + LOGE("%s::mSecHdmi.flush() fail\n", __func__); + } + + return true; +} +#endif sp SurfaceFlinger::createSurface( ISurfaceComposerClient::surface_data_t* params, const String8& name, -- cgit v1.2.3