diff --git a/liboverlay/overlayLib.cpp b/liboverlay/overlayLib.cpp index 73ea4fc..0d35e9b 100644 --- a/liboverlay/overlayLib.cpp +++ b/liboverlay/overlayLib.cpp @@ -19,6 +19,9 @@ #include "gralloc_priv.h" #define INTERLACE_MASK 0x80 +#define FBDEV_0 "/dev/graphics/fb0" +#define FBDEV_LEN strlen("msmfbXX_") +#define MDDI_PANEL '1' /* Helper functions */ static int get_mdp_format(int format) { @@ -140,7 +143,23 @@ static void reportError(const char* message) { using namespace overlay; Overlay::Overlay() : mChannelUP(false), mHDMIConnected(false), - mCloseChannel(false), mS3DFormat(0) { + mCloseChannel(false), mS3DFormat(0), mRotate(false) { + fb_fix_screeninfo finfo; + memset(&finfo, 0, sizeof(finfo)); + int fd = open(FBDEV_0, O_RDWR, 0); + if (fd < 0) { + reportError("Cant open framebuffer "); + return; + } else { + if(ioctl(fd, FBIOGET_FSCREENINFO, &finfo) == -1) { + reportError("FBIOGET_FSCREENINFO on fb0 failed"); + close(fd); + return; + } + if((finfo.id)[FBDEV_LEN] == MDDI_PANEL) + mRotate = true; + close(fd); + } } Overlay::~Overlay() { @@ -160,6 +179,9 @@ bool Overlay::startChannel(int w, int h, int format, int fbnum, unsigned int format3D, int channel, bool ignoreFB, int num_buffers) { int zorder = 0; + if( mRotate) + norot = 0; + if (format3D) zorder = channel; mChannelUP = objOvCtrlChannel[channel].startControlChannel(w, h, format, fbnum, @@ -303,7 +325,7 @@ bool Overlay::setSource(uint32_t w, uint32_t h, int format, int orientation, hdmiChanged = 0x1; stateChanged = s3dChanged|hdmiChanged; - if (stateChanged || !objOvCtrlChannel[0].setSource(w, h, colorFormat, orientation, ignoreFB)) { + if (stateChanged || !objOvCtrlChannel[0].setSource(w, h, colorFormat, orientation, ignoreFB, mRotate)) { if (mChannelUP && isRGBType(hw_format) && (stateChanged != 0x10)) { mCloseChannel = true; return false; @@ -539,6 +561,8 @@ bool OverlayControlChannel::openDevices(int fbnum) { return false; } + mFBPanelType = finfo.id[FBDEV_LEN]; + fb_var_screeninfo vinfo; if (ioctl(mFD, FBIOGET_VSCREENINFO, &vinfo) == -1) { reportError("FBIOGET_VSCREENINFO on fb1 failed"); @@ -648,7 +672,10 @@ bool OverlayControlChannel::startOVRotatorSessions(int w, int h, mRotInfo.src_rect.x = 0; mRotInfo.src_rect.y = 0; mRotInfo.rotations = 0; - mRotInfo.enable = 0; + if(mFBPanelType == MDDI_PANEL) + mRotInfo.enable = 1; + else + mRotInfo.enable = 0; mRotInfo.session_id = 0; int result = ioctl(mRotFD, MSM_ROTATOR_IOCTL_START, &mRotInfo); if (result) { @@ -734,19 +761,26 @@ bool OverlayControlChannel::closeControlChannel() { } bool OverlayControlChannel::setSource(uint32_t w, uint32_t h, - int format, int orientation, bool ignoreFB) { + int format, int orientation, bool ignoreFB, bool useRot) { format = get_mdp_format(format); - if ((orientation == mOrientation) - && ((orientation == OVERLAY_TRANSFORM_ROT_90) - || (orientation == OVERLAY_TRANSFORM_ROT_270))) { + if (useRot || ((orientation == mOrientation) && orientation)) { if (format == MDP_Y_CRCB_H2V2_TILE) { format = MDP_Y_CRCB_H2V2; w = (((w-1)/64 +1)*64); h = (((h-1)/32 +1)*32); } - int tmp = w; - w = h; - h = tmp; + switch(orientation){ + case OVERLAY_TRANSFORM_ROT_90: + case OVERLAY_TRANSFORM_ROT_270: + { + int tmp = w; + w = h; + h = tmp; + break; + } + default: + break; + } } if (w == mOVInfo.src.width && h == mOVInfo.src.height && format == mOVInfo.src.format && orientation == mOrientation) { @@ -945,6 +979,9 @@ bool OverlayControlChannel::setParameter(int param, int value, bool fetch) { else { if(mRotInfo.src.format == MDP_Y_CRCB_H2V2_TILE) mOVInfo.src.format = MDP_Y_CRCB_H2V2_TILE; + if(mFBPanelType == MDDI_PANEL) + mRotInfo.enable = 1; + else mRotInfo.enable = 0; } if (ioctl(mRotFD, MSM_ROTATOR_IOCTL_START, &mRotInfo)) { diff --git a/liboverlay/overlayLib.h b/liboverlay/overlayLib.h index fed1d59..2b8cda8 100644 --- a/liboverlay/overlayLib.h +++ b/liboverlay/overlayLib.h @@ -90,6 +90,7 @@ class OverlayControlChannel { int mFBHeight; int mFBbpp; int mFBystride; + char mFBPanelType; int mFD; int mRotFD; @@ -124,7 +125,7 @@ public: int getFormat3D() const { return mFormat3D; } bool getOrientation(int& orientation) const; bool setSource(uint32_t w, uint32_t h, int format, - int orientation, bool ignoreFB); + int orientation, bool ignoreFB, bool userot = false); bool getAspectRatioPosition(int w, int h, int format, overlay_rect *rect); bool getPositionS3D(int channel, int format, overlay_rect *rect); }; @@ -173,6 +174,7 @@ class Overlay { bool mHDMIConnected; int mS3DFormat; bool mCloseChannel; + bool mRotate; OverlayControlChannel objOvCtrlChannel[2]; OverlayDataChannel objOvDataChannel[2];