mdpWrapper.h revision f48aef64b218d42bd2ede62dcb03a3d7831ebbf9
129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/*
2f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed* Copyright (c) 2011, 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*/
2929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
3029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#ifndef MDP_WRAPPER_H
3129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#define MDP_WRAPPER_H
3229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
3329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/*
3429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* In order to make overlay::mdp_wrapper shorter, please do something like:
3529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* namespace mdpwrap = overlay::mdp_wrapper;
3629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* */
3729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
3829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include <linux/msm_mdp.h>
3929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include <linux/msm_rotator.h>
4029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include <sys/ioctl.h>
4129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include <utils/Log.h>
4229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include <errno.h>
4329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include "overlayUtils.h"
4429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
4529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmednamespace overlay{
4629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
4729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmednamespace mdp_wrapper{
4829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* FBIOGET_FSCREENINFO */
4929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool getFScreenInfo(int fd, fb_fix_screeninfo& finfo);
5029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
5129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* FBIOGET_VSCREENINFO */
5229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool getVScreenInfo(int fd, fb_var_screeninfo& vinfo);
5329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
5429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* FBIOPUT_VSCREENINFO */
5529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool setVScreenInfo(int fd, fb_var_screeninfo& vinfo);
5629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
5729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* MSM_ROTATOR_IOCTL_START */
5829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool startRotator(int fd, msm_rotator_img_info& rot);
5929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
6029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* MSM_ROTATOR_IOCTL_ROTATE */
6129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool rotate(int fd, msm_rotator_data_info& rot);
6229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
6329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* MSMFB_OVERLAY_SET */
6429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool setOverlay(int fd, mdp_overlay& ov);
6529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
6629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* MSM_ROTATOR_IOCTL_FINISH */
6729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool endRotator(int fd, int sessionId);
6829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
6929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* MSMFB_OVERLAY_UNSET */
7029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool unsetOverlay(int fd, int ovId);
7129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
7229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* MSMFB_OVERLAY_GET */
7329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool getOverlay(int fd, mdp_overlay& ov);
7429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
7529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* MSMFB_OVERLAY_PLAY */
7629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool play(int fd, msmfb_overlay_data& od);
7729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
7829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* MSMFB_OVERLAY_PLAY_WAIT */
79f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmedbool waitForVsync(int fd, msmfb_overlay_data& od);
8029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
8129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* MSMFB_OVERLAY_3D */
8229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedbool set3D(int fd, msmfb_overlay_3d& ov);
8329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
8429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* the following are helper functions for dumping
8529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed * msm_mdp and friends*/
8629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedvoid dump(const char* const s, const msmfb_overlay_data& ov);
8729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedvoid dump(const char* const s, const msmfb_data& ov);
8829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedvoid dump(const char* const s, const mdp_overlay& ov);
8929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedvoid dump(const char* const s, const msmfb_overlay_3d& ov);
9029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedvoid dump(const char* const s, const uint32_t u[], uint32_t cnt);
9129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedvoid dump(const char* const s, const msmfb_img& ov);
9229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedvoid dump(const char* const s, const mdp_rect& ov);
9329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
9429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* and rotator */
9529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedvoid dump(const char* const s, const msm_rotator_img_info& rot);
9629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedvoid dump(const char* const s, const msm_rotator_data_info& rot);
9729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
9829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* info */
9929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedvoid dump(const char* const s, const fb_fix_screeninfo& finfo);
10029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedvoid dump(const char* const s, const fb_var_screeninfo& vinfo);
10129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
10229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed//---------------Inlines -------------------------------------
10329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
10429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool getFScreenInfo(int fd, fb_fix_screeninfo& finfo) {
105f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed    if (ioctl(fd, FBIOGET_FSCREENINFO, &finfo) < 0) {
106f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed        ALOGE("Failed to call ioctl FBIOGET_FSCREENINFO err=%s",
107f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed                strerror(errno));
10829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed        return false;
10929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    }
11029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    return true;
11129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}
11229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
11329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool getVScreenInfo(int fd, fb_var_screeninfo& vinfo) {
114f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed    if (ioctl(fd, FBIOGET_VSCREENINFO, &vinfo) < 0) {
115f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed        ALOGE("Failed to call ioctl FBIOGET_VSCREENINFO err=%s",
116f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed                strerror(errno));
11729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed        return false;
11829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    }
11929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    return true;
12029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}
12129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
12229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool setVScreenInfo(int fd, fb_var_screeninfo& vinfo) {
123f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed    if (ioctl(fd, FBIOPUT_VSCREENINFO, &vinfo) < 0) {
124f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed        ALOGE("Failed to call ioctl FBIOPUT_VSCREENINFO err=%s",
125f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed                strerror(errno));
12629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed        return false;
12729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    }
12829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    return true;
12929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}
13029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
13129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool startRotator(int fd, msm_rotator_img_info& rot) {
132f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed    if (ioctl(fd, MSM_ROTATOR_IOCTL_START, &rot) < 0){
133f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed        ALOGE("Failed to call ioctl MSM_ROTATOR_IOCTL_START err=%s",
134f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed                strerror(errno));
13529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed        return false;
13629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    }
13729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    return true;
13829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}
13929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
14029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool rotate(int fd, msm_rotator_data_info& rot) {
141f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed    if (ioctl(fd, MSM_ROTATOR_IOCTL_ROTATE, &rot) < 0) {
142f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed        ALOGE("Failed to call ioctl MSM_ROTATOR_IOCTL_ROTATE err=%s",
143f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed                strerror(errno));
14429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed        return false;
14529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    }
14629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    return true;
14729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}
14829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
14929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool setOverlay(int fd, mdp_overlay& ov) {
150f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed    if (ioctl(fd, MSMFB_OVERLAY_SET, &ov) < 0) {
151f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed        ALOGE("Failed to call ioctl MSMFB_OVERLAY_SET err=%s",
152f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed                strerror(errno));
15329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed        return false;
15429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    }
15529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    return true;
15629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}
15729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
15829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool endRotator(int fd, int sessionId) {
159f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed    if (ioctl(fd, MSM_ROTATOR_IOCTL_FINISH, &sessionId) < 0) {
160f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed        ALOGE("Failed to call ioctl MSM_ROTATOR_IOCTL_FINISH err=%s",
161f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed                strerror(errno));
16229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed        return false;
16329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    }
16429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    return true;
16529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}
16629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
16729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool unsetOverlay(int fd, int ovId) {
168f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed    if (ioctl(fd, MSMFB_OVERLAY_UNSET, &ovId) < 0) {
169f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed        ALOGE("Failed to call ioctl MSMFB_OVERLAY_UNSET err=%s",
170f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed                strerror(errno));
17129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed        return false;
17229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    }
17329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    return true;
17429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}
17529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
17629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool getOverlay(int fd, mdp_overlay& ov) {
177f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed    if (ioctl(fd, MSMFB_OVERLAY_GET, &ov) < 0) {
178f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed        ALOGE("Failed to call ioctl MSMFB_OVERLAY_GET err=%s",
179f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed                strerror(errno));
18029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed        return false;
18129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    }
18229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    return true;
18329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}
18429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
18529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool play(int fd, msmfb_overlay_data& od) {
186f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed    if (ioctl(fd, MSMFB_OVERLAY_PLAY, &od) < 0) {
187f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed        ALOGE("Failed to call ioctl MSMFB_OVERLAY_PLAY err=%s",
188f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed                strerror(errno));
18929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed        return false;
19029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    }
19129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    return true;
19229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}
19329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
194f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmedinline bool waitForVsync(int fd, msmfb_overlay_data& od) {
195f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed    if (ioctl(fd, MSMFB_OVERLAY_PLAY_WAIT, &od) < 0) {
196f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed        ALOGE("Failed to call ioctl MSMFB_OVERLAY_PLAY_WAIT err=%s",
197f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed                strerror(errno));
19829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed        return false;
19929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    }
20029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    return true;
20129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}
20229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
20329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline bool set3D(int fd, msmfb_overlay_3d& ov) {
204f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed    if (ioctl(fd, MSMFB_OVERLAY_3D, &ov) < 0) {
205f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed        ALOGE("Failed to call ioctl MSMFB_OVERLAY_3D err=%s",
206f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed                strerror(errno));
20729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed        return false;
20829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    }
20929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    return true;
21029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}
21129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
21229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/* dump funcs */
21329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void dump(const char* const s, const msmfb_overlay_data& ov) {
21429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    ALOGE("%s msmfb_overlay_data id=%d",
21529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed            s, ov.id);
21629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    dump("data", ov.data);
21729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}
21829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void dump(const char* const s, const msmfb_data& ov) {
21929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    ALOGE("%s msmfb_data offset=%d memid=%d id=%d flags=0x%x priv=%d",
22029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed            s, ov.offset, ov.memory_id, ov.id, ov.flags, ov.priv);
22129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}
22229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void dump(const char* const s, const mdp_overlay& ov) {
22329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    ALOGE("%s mdp_overlay z=%d fg=%d alpha=%d mask=%d flags=0x%x id=%d",
22429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed            s, ov.z_order, ov.is_fg, ov.alpha,
22529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed            ov.transp_mask, ov.flags, ov.id);
22629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    dump("src", ov.src);
22729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    dump("src_rect", ov.src_rect);
22829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    dump("dst_rect", ov.dst_rect);
22929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    dump("user_data", ov.user_data,
23029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed            sizeof(ov.user_data)/sizeof(ov.user_data[0]));
23129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}
23229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void dump(const char* const s, const msmfb_img& ov) {
23329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    ALOGE("%s msmfb_img w=%d h=%d format=%d %s",
23429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed            s, ov.width, ov.height, ov.format,
23529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed            overlay::utils::getFormatString(ov.format));
23629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}
23729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void dump(const char* const s, const mdp_rect& ov) {
23829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    ALOGE("%s mdp_rect x=%d y=%d w=%d h=%d",
23929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed            s, ov.x, ov.y, ov.w, ov.h);
24029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}
24129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
24229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void dump(const char* const s, const msmfb_overlay_3d& ov) {
24329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    ALOGE("%s msmfb_overlay_3d 3d=%d w=%d h=%d",
24429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed            s, ov.is_3d, ov.width, ov.height);
24529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
24629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}
24729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void dump(const char* const s, const uint32_t u[], uint32_t cnt) {
24829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    ALOGE("%s user_data cnt=%d", s, cnt);
24929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    for(uint32_t i=0; i < cnt; ++i) {
25029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed        ALOGE("i=%d val=%d", i, u[i]);
25129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    }
25229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}
25329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void dump(const char* const s, const msm_rotator_img_info& rot) {
25429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    ALOGE("%s msm_rotator_img_info sessid=%d dstx=%d dsty=%d rot=%d, ena=%d",
25529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed            s, rot.session_id, rot.dst_x, rot.dst_y,
25629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed            rot.rotations, rot.enable);
25729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    dump("src", rot.src);
25829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    dump("dst", rot.dst);
25929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    dump("src_rect", rot.src_rect);
26029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}
26129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void dump(const char* const s, const msm_rotator_data_info& rot) {
26229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    ALOGE("%s msm_rotator_data_info sessid=%d verkey=%d",
26329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed            s, rot.session_id, rot.version_key);
26429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    dump("src", rot.src);
26529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    dump("dst", rot.dst);
26629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    dump("src_chroma", rot.src_chroma);
26729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    dump("dst_chroma", rot.dst_chroma);
26829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}
26929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void dump(const char* const s, const fb_fix_screeninfo& finfo) {
27029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    ALOGE("%s fb_fix_screeninfo type=%d", s, finfo.type);
27129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}
27229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedinline void dump(const char* const s, const fb_var_screeninfo& vinfo) {
27329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    ALOGE("%s fb_var_screeninfo xres=%d yres=%d",
27429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed            s, vinfo.xres, vinfo.yres);
27529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed}
27629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
27729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} // mdp_wrapper
27829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
27929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} // overlay
28029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
28129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#endif // MDP_WRAPPER_H
282