mdp_version.cpp revision a87da60090f55b823ee999930b381daa3dbda67e
129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* 229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * Copyright (c) 2012, Code Aurora Forum. All rights reserved. 329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * Redistribution and use in source and binary forms, with or without 529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * modification, are permitted provided that the following conditions are 629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * met: 729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * * Redistributions of source code must retain the above copyright 829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * notice, this list of conditions and the following disclaimer. 929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * * Redistributions in binary form must reproduce the above 1029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * copyright notice, this list of conditions and the following 1129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * disclaimer in the documentation and/or other materials provided 1229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * with the distribution. 1329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * * Neither the name of Code Aurora Forum, Inc. nor the names of its 1429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * contributors may be used to endorse or promote products derived 1529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * from this software without specific prior written permission. 1629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * 1729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 1829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 1929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 2029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 2129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 2429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 2529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 2629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 2729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed */ 29a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed#include <cutils/log.h> 30a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed#include <fcntl.h> 31a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed#include <linux/fb.h> 32a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed#include "mdp_version.h" 3329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 34a87da60090f55b823ee999930b381daa3dbda67eNaseer AhmedANDROID_SINGLETON_STATIC_INSTANCE(qdutils::MDPVersion); 35a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmednamespace qdutils { 3629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 37a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmedstatic int getMDPVersionFromFB() 38a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed{ 39a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed int fb_fd = open("/dev/graphics/fb0", O_RDWR); 40a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed int mdp_version = MDP_V_UNKNOWN; 41a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed struct fb_fix_screeninfo fb_finfo; 42a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed if (ioctl(fb_fd, FBIOGET_FSCREENINFO, &fb_finfo) < 0) { 43a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed ALOGE("FBIOGET_FSCREENINFO failed"); 44a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed mdp_version = MDP_V_UNKNOWN; 45a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed } else { 46a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed if(!strncmp(fb_finfo.id, "msmfb", 5)) { 47a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed char str_ver[4] = { 0 }; 48a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed memcpy(str_ver, &fb_finfo.id[5], 3); 49a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed str_ver[3] = '\0'; 50a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed mdp_version = atoi(str_ver); 5129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 52a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed //Normalize MDP version to ease comparison. 53a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed //This is needed only because 54a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed //MDP 3.0.3 reports value as 303 which 55a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed //is more than all the others 56a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed if (mdp_version < 100) 57a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed mdp_version *= 10; 5829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 59a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed } else if (!strncmp(fb_finfo.id, "mdssfb", 6)) { 60a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed mdp_version = MDSS_V5; 61a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed } else { 62a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed mdp_version = MDP_V_UNKNOWN; 63a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed } 64a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed } 65a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed close(fb_fd); 66a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed return mdp_version; 67a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed} 6829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 69a87da60090f55b823ee999930b381daa3dbda67eNaseer AhmedMDPVersion::MDPVersion() 70a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed{ 71a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed mMDPVersion = getMDPVersionFromFB(); 72a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed if((mMDPVersion >= MDP_V4_0) || (mMDPVersion == MDP_V_UNKNOWN)) 73a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed mHasOverlay = true; 74a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed else 75a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed mHasOverlay = false; 76a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed} 77a87da60090f55b823ee999930b381daa3dbda67eNaseer Ahmed}; //namespace qdutils 7829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 79