129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* 2d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed* Copyright (c) 2011, The Linux Foundation. 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. 13d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed* * Neither the name of The Linux Foundation 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*/ 2929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 3029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#ifndef MDP_WRAPPER_H 3129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#define MDP_WRAPPER_H 32c20104e1c005e4e47adea555e53e176b6dbe4be1Naseer Ahmed#define ATRACE_TAG (ATRACE_TAG_GRAPHICS | ATRACE_TAG_HAL) 3329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 3429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* 3529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* In order to make overlay::mdp_wrapper shorter, please do something like: 3629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* namespace mdpwrap = overlay::mdp_wrapper; 3729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* */ 3829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 3929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include <linux/msm_mdp.h> 4029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include <linux/msm_rotator.h> 4129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include <sys/ioctl.h> 4229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include <utils/Log.h> 4329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include <errno.h> 4429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include "overlayUtils.h" 45c20104e1c005e4e47adea555e53e176b6dbe4be1Naseer Ahmed#include <utils/Trace.h> 4629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 4729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmednamespace overlay{ 4829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 4929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmednamespace mdp_wrapper{ 5029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* FBIOGET_FSCREENINFO */ 5129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool getFScreenInfo(int fd, fb_fix_screeninfo& finfo); 5229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 5329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* FBIOGET_VSCREENINFO */ 5429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool getVScreenInfo(int fd, fb_var_screeninfo& vinfo); 5529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 5629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* FBIOPUT_VSCREENINFO */ 5729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool setVScreenInfo(int fd, fb_var_screeninfo& vinfo); 5829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 5929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* MSM_ROTATOR_IOCTL_START */ 6029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool startRotator(int fd, msm_rotator_img_info& rot); 6129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 6229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* MSM_ROTATOR_IOCTL_ROTATE */ 6329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool rotate(int fd, msm_rotator_data_info& rot); 6429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 6529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* MSMFB_OVERLAY_SET */ 6629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool setOverlay(int fd, mdp_overlay& ov); 6729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 6829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* MSM_ROTATOR_IOCTL_FINISH */ 6929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool endRotator(int fd, int sessionId); 7029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 7129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* MSMFB_OVERLAY_UNSET */ 7229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool unsetOverlay(int fd, int ovId); 7329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 7429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* MSMFB_OVERLAY_GET */ 7529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool getOverlay(int fd, mdp_overlay& ov); 7629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 7729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* MSMFB_OVERLAY_PLAY */ 7829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool play(int fd, msmfb_overlay_data& od); 7929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 8029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* MSMFB_OVERLAY_3D */ 8129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool set3D(int fd, msmfb_overlay_3d& ov); 8229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 835ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah/* MSMFB_DISPLAY_COMMIT */ 845ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shahbool displayCommit(int fd); 855ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah 865ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah/* MSMFB_WRITEBACK_INIT, MSMFB_WRITEBACK_START */ 875ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shahbool wbInitStart(int fbfd); 885ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah 895ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah/* MSMFB_WRITEBACK_STOP, MSMFB_WRITEBACK_TERMINATE */ 905ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shahbool wbStopTerminate(int fbfd); 915ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah 925ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah/* MSMFB_WRITEBACK_QUEUE_BUFFER */ 935ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shahbool wbQueueBuffer(int fbfd, struct msmfb_data& fbData); 945ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah 955ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah/* MSMFB_WRITEBACK_DEQUEUE_BUFFER */ 965ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shahbool wbDequeueBuffer(int fbfd, struct msmfb_data& fbData); 975ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah 9829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* the following are helper functions for dumping 9929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * msm_mdp and friends*/ 10029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedvoid dump(const char* const s, const msmfb_overlay_data& ov); 10129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedvoid dump(const char* const s, const msmfb_data& ov); 10229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedvoid dump(const char* const s, const mdp_overlay& ov); 10329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedvoid dump(const char* const s, const msmfb_overlay_3d& ov); 10429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedvoid dump(const char* const s, const uint32_t u[], uint32_t cnt); 10529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedvoid dump(const char* const s, const msmfb_img& ov); 10629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedvoid dump(const char* const s, const mdp_rect& ov); 10729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 10829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* and rotator */ 10929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedvoid dump(const char* const s, const msm_rotator_img_info& rot); 11029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedvoid dump(const char* const s, const msm_rotator_data_info& rot); 11129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 11229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* info */ 11329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedvoid dump(const char* const s, const fb_fix_screeninfo& finfo); 11429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedvoid dump(const char* const s, const fb_var_screeninfo& vinfo); 11529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 11629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed//---------------Inlines ------------------------------------- 11729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 11829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool getFScreenInfo(int fd, fb_fix_screeninfo& finfo) { 119c20104e1c005e4e47adea555e53e176b6dbe4be1Naseer Ahmed ATRACE_CALL(); 120f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed if (ioctl(fd, FBIOGET_FSCREENINFO, &finfo) < 0) { 121f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed ALOGE("Failed to call ioctl FBIOGET_FSCREENINFO err=%s", 122f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed strerror(errno)); 12329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return false; 12429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 12529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return true; 12629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 12729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 12829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool getVScreenInfo(int fd, fb_var_screeninfo& vinfo) { 129c20104e1c005e4e47adea555e53e176b6dbe4be1Naseer Ahmed ATRACE_CALL(); 130f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed if (ioctl(fd, FBIOGET_VSCREENINFO, &vinfo) < 0) { 131f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed ALOGE("Failed to call ioctl FBIOGET_VSCREENINFO err=%s", 132f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed strerror(errno)); 13329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return false; 13429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 13529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return true; 13629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 13729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 13829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool setVScreenInfo(int fd, fb_var_screeninfo& vinfo) { 139c20104e1c005e4e47adea555e53e176b6dbe4be1Naseer Ahmed ATRACE_CALL(); 140f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed if (ioctl(fd, FBIOPUT_VSCREENINFO, &vinfo) < 0) { 141f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed ALOGE("Failed to call ioctl FBIOPUT_VSCREENINFO err=%s", 142f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed strerror(errno)); 14329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return false; 14429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 14529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return true; 14629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 14729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 14829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool startRotator(int fd, msm_rotator_img_info& rot) { 149c20104e1c005e4e47adea555e53e176b6dbe4be1Naseer Ahmed ATRACE_CALL(); 150f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed if (ioctl(fd, MSM_ROTATOR_IOCTL_START, &rot) < 0){ 151f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed ALOGE("Failed to call ioctl MSM_ROTATOR_IOCTL_START err=%s", 152f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed strerror(errno)); 15329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return false; 15429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 15529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return true; 15629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 15729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 15829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool rotate(int fd, msm_rotator_data_info& rot) { 159c20104e1c005e4e47adea555e53e176b6dbe4be1Naseer Ahmed ATRACE_CALL(); 160f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed if (ioctl(fd, MSM_ROTATOR_IOCTL_ROTATE, &rot) < 0) { 161f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed ALOGE("Failed to call ioctl MSM_ROTATOR_IOCTL_ROTATE err=%s", 162f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed strerror(errno)); 16329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return false; 16429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 16529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return true; 16629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 16729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 16829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool setOverlay(int fd, mdp_overlay& ov) { 169c20104e1c005e4e47adea555e53e176b6dbe4be1Naseer Ahmed ATRACE_CALL(); 170f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed if (ioctl(fd, MSMFB_OVERLAY_SET, &ov) < 0) { 171f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed ALOGE("Failed to call ioctl MSMFB_OVERLAY_SET err=%s", 172f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed strerror(errno)); 17329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return false; 17429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 17529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return true; 17629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 17729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 178d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmedinline bool endRotator(int fd, uint32_t sessionId) { 179c20104e1c005e4e47adea555e53e176b6dbe4be1Naseer Ahmed ATRACE_CALL(); 180f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed if (ioctl(fd, MSM_ROTATOR_IOCTL_FINISH, &sessionId) < 0) { 181f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed ALOGE("Failed to call ioctl MSM_ROTATOR_IOCTL_FINISH err=%s", 182f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed strerror(errno)); 18329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return false; 18429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 18529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return true; 18629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 18729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 18829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool unsetOverlay(int fd, int ovId) { 189c20104e1c005e4e47adea555e53e176b6dbe4be1Naseer Ahmed ATRACE_CALL(); 190f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed if (ioctl(fd, MSMFB_OVERLAY_UNSET, &ovId) < 0) { 191f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed ALOGE("Failed to call ioctl MSMFB_OVERLAY_UNSET err=%s", 192f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed strerror(errno)); 19329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return false; 19429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 19529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return true; 19629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 19729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 19829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool getOverlay(int fd, mdp_overlay& ov) { 199c20104e1c005e4e47adea555e53e176b6dbe4be1Naseer Ahmed ATRACE_CALL(); 200f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed if (ioctl(fd, MSMFB_OVERLAY_GET, &ov) < 0) { 201f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed ALOGE("Failed to call ioctl MSMFB_OVERLAY_GET err=%s", 202f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed strerror(errno)); 20329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return false; 20429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 20529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return true; 20629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 20729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 20829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool play(int fd, msmfb_overlay_data& od) { 209c20104e1c005e4e47adea555e53e176b6dbe4be1Naseer Ahmed ATRACE_CALL(); 210f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed if (ioctl(fd, MSMFB_OVERLAY_PLAY, &od) < 0) { 211f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed ALOGE("Failed to call ioctl MSMFB_OVERLAY_PLAY err=%s", 212f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed strerror(errno)); 21329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return false; 21429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 21529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return true; 21629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 21729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 21829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool set3D(int fd, msmfb_overlay_3d& ov) { 219c20104e1c005e4e47adea555e53e176b6dbe4be1Naseer Ahmed ATRACE_CALL(); 220f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed if (ioctl(fd, MSMFB_OVERLAY_3D, &ov) < 0) { 221f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed ALOGE("Failed to call ioctl MSMFB_OVERLAY_3D err=%s", 222f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed strerror(errno)); 22329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return false; 22429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 22529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed return true; 22629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 22729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 2285ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shahinline bool displayCommit(int fd, mdp_display_commit& info) { 229c20104e1c005e4e47adea555e53e176b6dbe4be1Naseer Ahmed ATRACE_CALL(); 2305ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah if(ioctl(fd, MSMFB_DISPLAY_COMMIT, &info) == -1) { 2315ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah ALOGE("Failed to call ioctl MSMFB_DISPLAY_COMMIT err=%s", 2325ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah strerror(errno)); 2335ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah return false; 2345ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah } 2355ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah return true; 2365ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah} 2375ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah 2385ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shahinline bool wbInitStart(int fbfd) { 239c20104e1c005e4e47adea555e53e176b6dbe4be1Naseer Ahmed ATRACE_CALL(); 2405ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah if(ioctl(fbfd, MSMFB_WRITEBACK_INIT, NULL) < 0) { 2415ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah ALOGE("Failed to call ioctl MSMFB_WRITEBACK_INIT err=%s", 2425ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah strerror(errno)); 2435ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah return false; 2445ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah } 2455ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah if(ioctl(fbfd, MSMFB_WRITEBACK_START, NULL) < 0) { 2465ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah ALOGE("Failed to call ioctl MSMFB_WRITEBACK_START err=%s", 2475ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah strerror(errno)); 2485ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah return false; 2495ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah } 2505ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah return true; 2515ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah} 2525ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah 2535ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shahinline bool wbStopTerminate(int fbfd) { 254c20104e1c005e4e47adea555e53e176b6dbe4be1Naseer Ahmed ATRACE_CALL(); 2555ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah if(ioctl(fbfd, MSMFB_WRITEBACK_STOP, NULL) < 0) { 2565ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah ALOGE("Failed to call ioctl MSMFB_WRITEBACK_STOP err=%s", 2575ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah strerror(errno)); 2585ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah return false; 2595ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah } 2605ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah if(ioctl(fbfd, MSMFB_WRITEBACK_TERMINATE, NULL) < 0) { 2615ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah ALOGE("Failed to call ioctl MSMFB_WRITEBACK_TERMINATE err=%s", 2625ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah strerror(errno)); 2635ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah return false; 2645ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah } 2655ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah return true; 2665ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah} 2675ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah 2685ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shahinline bool wbQueueBuffer(int fbfd, struct msmfb_data& fbData) { 269c20104e1c005e4e47adea555e53e176b6dbe4be1Naseer Ahmed ATRACE_CALL(); 2705ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah if(ioctl(fbfd, MSMFB_WRITEBACK_QUEUE_BUFFER, &fbData) < 0) { 2715ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah ALOGE("Failed to call ioctl MSMFB_WRITEBACK_QUEUE_BUFFER err=%s", 2725ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah strerror(errno)); 2735ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah return false; 2745ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah } 2755ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah return true; 2765ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah} 2775ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah 2785ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shahinline bool wbDequeueBuffer(int fbfd, struct msmfb_data& fbData) { 279c20104e1c005e4e47adea555e53e176b6dbe4be1Naseer Ahmed ATRACE_CALL(); 2805ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah if(ioctl(fbfd, MSMFB_WRITEBACK_DEQUEUE_BUFFER, &fbData) < 0) { 2815ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah ALOGE("Failed to call ioctl MSMFB_WRITEBACK_DEQUEUE_BUFFER err=%s", 2825ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah strerror(errno)); 2835ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah return false; 2845ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah } 2855ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah return true; 2865ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah} 2875ceb9c6a763418d5e0cf5da4e74b7a7c733fb4b1Saurabh Shah 28829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* dump funcs */ 28929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void dump(const char* const s, const msmfb_overlay_data& ov) { 29029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("%s msmfb_overlay_data id=%d", 29129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed s, ov.id); 29229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed dump("data", ov.data); 29329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 29429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void dump(const char* const s, const msmfb_data& ov) { 29529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("%s msmfb_data offset=%d memid=%d id=%d flags=0x%x priv=%d", 29629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed s, ov.offset, ov.memory_id, ov.id, ov.flags, ov.priv); 29729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 29829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void dump(const char* const s, const mdp_overlay& ov) { 29929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("%s mdp_overlay z=%d fg=%d alpha=%d mask=%d flags=0x%x id=%d", 30029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed s, ov.z_order, ov.is_fg, ov.alpha, 30129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ov.transp_mask, ov.flags, ov.id); 30229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed dump("src", ov.src); 30329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed dump("src_rect", ov.src_rect); 30429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed dump("dst_rect", ov.dst_rect); 305d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed /* 306d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed Commented off to prevent verbose logging, since user_data could have 8 or so 307d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed fields which are mostly 0 30829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed dump("user_data", ov.user_data, 30929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed sizeof(ov.user_data)/sizeof(ov.user_data[0])); 310d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed */ 31129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 31229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void dump(const char* const s, const msmfb_img& ov) { 31329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("%s msmfb_img w=%d h=%d format=%d %s", 31429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed s, ov.width, ov.height, ov.format, 31529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed overlay::utils::getFormatString(ov.format)); 31629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 31729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void dump(const char* const s, const mdp_rect& ov) { 31829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("%s mdp_rect x=%d y=%d w=%d h=%d", 31929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed s, ov.x, ov.y, ov.w, ov.h); 32029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 32129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 32229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void dump(const char* const s, const msmfb_overlay_3d& ov) { 32329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("%s msmfb_overlay_3d 3d=%d w=%d h=%d", 32429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed s, ov.is_3d, ov.width, ov.height); 32529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 32629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 32729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void dump(const char* const s, const uint32_t u[], uint32_t cnt) { 32829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("%s user_data cnt=%d", s, cnt); 32929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed for(uint32_t i=0; i < cnt; ++i) { 33029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("i=%d val=%d", i, u[i]); 33129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed } 33229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 33329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void dump(const char* const s, const msm_rotator_img_info& rot) { 334d82ce1da8ebdba46e6d0119fac1aa8d4b9b033b7Ramkumar Radhakrishnan ALOGE("%s msm_rotator_img_info sessid=%u dstx=%d dsty=%d rot=%d, ena=%d scale=%d", 33529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed s, rot.session_id, rot.dst_x, rot.dst_y, 336d82ce1da8ebdba46e6d0119fac1aa8d4b9b033b7Ramkumar Radhakrishnan rot.rotations, rot.enable, rot.downscale_ratio); 33729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed dump("src", rot.src); 33829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed dump("dst", rot.dst); 33929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed dump("src_rect", rot.src_rect); 34029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 34129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void dump(const char* const s, const msm_rotator_data_info& rot) { 342d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed ALOGE("%s msm_rotator_data_info sessid=%u verkey=%d", 34329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed s, rot.session_id, rot.version_key); 34429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed dump("src", rot.src); 34529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed dump("dst", rot.dst); 34629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed dump("src_chroma", rot.src_chroma); 34729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed dump("dst_chroma", rot.dst_chroma); 34829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 34929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void dump(const char* const s, const fb_fix_screeninfo& finfo) { 35029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("%s fb_fix_screeninfo type=%d", s, finfo.type); 35129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 35229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void dump(const char* const s, const fb_var_screeninfo& vinfo) { 35329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed ALOGE("%s fb_var_screeninfo xres=%d yres=%d", 35429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed s, vinfo.xres, vinfo.yres); 35529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} 35629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 35729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} // mdp_wrapper 35829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 35929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} // overlay 36029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed 36129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#endif // MDP_WRAPPER_H 362