blob: 8196fe7fd764e94fd87aaba7d9d823fc65e7acf8 [file] [log] [blame]
Naseer Ahmedf48aef62012-07-20 09:05:53 -07001/*
2* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are
6* met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above
10* copyright notice, this list of conditions and the following
11* disclaimer in the documentation and/or other materials provided
12* with the distribution.
13* * Neither the name of Code Aurora Forum, Inc. nor the names of its
14* contributors may be used to endorse or promote products derived
15* from this software without specific prior written permission.
16*
17* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*/
29
30#ifndef OVERLAY_VIDEO_EXT_PIPE_H
31#define OVERLAY_VIDEO_EXT_PIPE_H
32
33#include "overlayGenPipe.h"
34#include "overlayUtils.h"
35#include "overlayCtrlData.h"
36#include "overlayMdp.h"
37#include "overlayRotator.h"
38
39namespace overlay {
40
41/* A specific impl of GenericPipe
42* Whenever needed to have a pass through - we do it.
43* If there is a special need for a different behavior - do it here */
44class VideoExtPipe : utils::NoCopy {
45public:
46 /* Please look at overlayGenPipe.h for info */
47 explicit VideoExtPipe();
48 ~VideoExtPipe();
49 bool init(RotatorBase* rot);
50 bool close();
51 bool commit();
52 bool queueBuffer(int fd, uint32_t offset);
53 bool waitForVsync();
54 bool setCrop(const utils::Dim& dim);
55 bool setPosition(const utils::Dim& dim);
56 bool setTransform(const utils::eTransform& param);
57 bool setSource(const utils::PipeArgs& args);
58 utils::eOverlayPipeType getOvPipeType() const;
59 void dump() const;
60private:
61 overlay::GenericPipe<ovutils::EXTERNAL> mVideoExt;
62};
63
64//------------------Inlines -----------------------------
65
66inline VideoExtPipe::VideoExtPipe() {}
67inline VideoExtPipe::~VideoExtPipe() { close(); }
68inline bool VideoExtPipe::init(RotatorBase* rot) {
69 ALOGE_IF(DEBUG_OVERLAY, "VideoExtPipe init");
70 return mVideoExt.init(rot);
71}
72inline bool VideoExtPipe::close() { return mVideoExt.close(); }
73inline bool VideoExtPipe::commit() { return mVideoExt.commit(); }
74inline bool VideoExtPipe::queueBuffer(int fd, uint32_t offset) {
75 return mVideoExt.queueBuffer(fd, offset);
76}
77inline bool VideoExtPipe::waitForVsync() {
78 return mVideoExt.waitForVsync();
79}
80inline bool VideoExtPipe::setCrop(const utils::Dim& dim) {
81 return mVideoExt.setCrop(dim);
82}
83inline bool VideoExtPipe::setPosition(const utils::Dim& dim)
84{
85 utils::Dim d;
86 // Need to change dim to aspect ratio
87 if (utils::FrameBufferInfo::getInstance()->supportTrueMirroring()) {
88 // Use dim info to calculate aspect ratio for true UI mirroring
89 d = mVideoExt.getAspectRatio(dim);
90 } else {
91 // Use cached crop data to get aspect ratio
92 utils::Dim crop = mVideoExt.getCrop();
93 utils::Whf whf(crop.w, crop.h, 0);
94 d = mVideoExt.getAspectRatio(whf);
95 }
96 ALOGE_IF(DEBUG_OVERLAY, "Calculated aspect ratio for EXT: x=%d, y=%d, w=%d,"
97 "h=%d, o=%d",
98 d.x, d.y, d.w, d.h, d.o);
99 return mVideoExt.setPosition(d);
100}
101inline bool VideoExtPipe::setTransform(const utils::eTransform& param) {
102 return mVideoExt.setTransform(param);
103}
104inline bool VideoExtPipe::setSource(const utils::PipeArgs& args) {
105 utils::PipeArgs arg(args);
106 return mVideoExt.setSource(arg);
107}
108inline utils::eOverlayPipeType VideoExtPipe::getOvPipeType() const {
109 return utils::OV_PIPE_TYPE_VIDEO_EXT;
110}
111inline void VideoExtPipe::dump() const {
112 ALOGE("Video Ext Pipe");
113 mVideoExt.dump();
114}
115
116
117} // overlay
118
119#endif // OVERLAY_VIDEO_EXT_PIPE_H