blob: d4e1f3fe51af4817e63157f3a448fa2d6a40d155 [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);
Naseer Ahmedf48aef62012-07-20 09:05:53 -070053 bool setCrop(const utils::Dim& dim);
54 bool setPosition(const utils::Dim& dim);
55 bool setTransform(const utils::eTransform& param);
56 bool setSource(const utils::PipeArgs& args);
Naseer Ahmedf48aef62012-07-20 09:05:53 -070057 void dump() const;
58private:
59 overlay::GenericPipe<ovutils::EXTERNAL> mVideoExt;
60};
61
62//------------------Inlines -----------------------------
63
64inline VideoExtPipe::VideoExtPipe() {}
65inline VideoExtPipe::~VideoExtPipe() { close(); }
66inline bool VideoExtPipe::init(RotatorBase* rot) {
67 ALOGE_IF(DEBUG_OVERLAY, "VideoExtPipe init");
68 return mVideoExt.init(rot);
69}
70inline bool VideoExtPipe::close() { return mVideoExt.close(); }
71inline bool VideoExtPipe::commit() { return mVideoExt.commit(); }
72inline bool VideoExtPipe::queueBuffer(int fd, uint32_t offset) {
73 return mVideoExt.queueBuffer(fd, offset);
74}
Naseer Ahmedf48aef62012-07-20 09:05:53 -070075inline bool VideoExtPipe::setCrop(const utils::Dim& dim) {
76 return mVideoExt.setCrop(dim);
77}
78inline bool VideoExtPipe::setPosition(const utils::Dim& dim)
79{
80 utils::Dim d;
81 // Need to change dim to aspect ratio
82 if (utils::FrameBufferInfo::getInstance()->supportTrueMirroring()) {
83 // Use dim info to calculate aspect ratio for true UI mirroring
84 d = mVideoExt.getAspectRatio(dim);
85 } else {
86 // Use cached crop data to get aspect ratio
87 utils::Dim crop = mVideoExt.getCrop();
88 utils::Whf whf(crop.w, crop.h, 0);
89 d = mVideoExt.getAspectRatio(whf);
90 }
91 ALOGE_IF(DEBUG_OVERLAY, "Calculated aspect ratio for EXT: x=%d, y=%d, w=%d,"
92 "h=%d, o=%d",
93 d.x, d.y, d.w, d.h, d.o);
94 return mVideoExt.setPosition(d);
95}
96inline bool VideoExtPipe::setTransform(const utils::eTransform& param) {
97 return mVideoExt.setTransform(param);
98}
99inline bool VideoExtPipe::setSource(const utils::PipeArgs& args) {
100 utils::PipeArgs arg(args);
101 return mVideoExt.setSource(arg);
102}
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700103inline void VideoExtPipe::dump() const {
104 ALOGE("Video Ext Pipe");
105 mVideoExt.dump();
106}
107
108
109} // overlay
110
111#endif // OVERLAY_VIDEO_EXT_PIPE_H