blob: aebaebfbcd366561e059bcace7138e8cbe04b1a5 [file] [log] [blame]
Naseer Ahmed758bfc52012-11-28 17:02:08 -05001/*
Raj kamal23f69b22012-11-17 00:20:55 +05302* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
Naseer Ahmed758bfc52012-11-28 17:02:08 -05003*
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 The Linux Foundation 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#include "overlayGenPipe.h"
Ramkumar Radhakrishnan288f8c72013-01-15 11:37:54 -080031#include "mdp_version.h"
Naseer Ahmed758bfc52012-11-28 17:02:08 -050032
33namespace overlay {
34
Saurabh Shah958051e2014-06-27 16:15:42 -070035GenericPipe::GenericPipe(const int& dpy) : mDpy(dpy),
36 mCtrl(new Ctrl(dpy)), mData(new Data(dpy)) {
Naseer Ahmed758bfc52012-11-28 17:02:08 -050037}
38
39GenericPipe::~GenericPipe() {
Saurabh Shahd18d88a2014-01-06 15:02:49 -080040 delete mCtrl;
41 delete mData;
Naseer Ahmed758bfc52012-11-28 17:02:08 -050042}
43
Saurabh Shahacf10202013-02-26 10:15:15 -080044void GenericPipe::setSource(const utils::PipeArgs& args) {
Saurabh Shahd18d88a2014-01-06 15:02:49 -080045 mCtrl->setSource(args);
Naseer Ahmed758bfc52012-11-28 17:02:08 -050046}
47
Saurabh Shahacf10202013-02-26 10:15:15 -080048void GenericPipe::setCrop(const overlay::utils::Dim& d) {
Saurabh Shahd18d88a2014-01-06 15:02:49 -080049 mCtrl->setCrop(d);
Naseer Ahmed758bfc52012-11-28 17:02:08 -050050}
51
Sushil Chauhan897a9c32013-07-18 11:09:55 -070052void GenericPipe::setColor(const uint32_t color) {
Saurabh Shahd18d88a2014-01-06 15:02:49 -080053 mCtrl->setColor(color);
Sushil Chauhan897a9c32013-07-18 11:09:55 -070054}
55
Saurabh Shahacf10202013-02-26 10:15:15 -080056void GenericPipe::setTransform(const utils::eTransform& orient) {
Saurabh Shahd18d88a2014-01-06 15:02:49 -080057 mCtrl->setTransform(orient);
Naseer Ahmed758bfc52012-11-28 17:02:08 -050058}
59
Saurabh Shahacf10202013-02-26 10:15:15 -080060void GenericPipe::setPosition(const utils::Dim& d) {
Saurabh Shahd18d88a2014-01-06 15:02:49 -080061 mCtrl->setPosition(d);
Ramkumar Radhakrishnan288f8c72013-01-15 11:37:54 -080062}
63
Saurabh Shah5daeee52013-01-23 16:52:26 +080064bool GenericPipe::setVisualParams(const MetaData_t &metadata)
65{
Saurabh Shahd18d88a2014-01-06 15:02:49 -080066 return mCtrl->setVisualParams(metadata);
Saurabh Shah5daeee52013-01-23 16:52:26 +080067}
68
radhakrishna8ccb9082014-05-09 16:18:43 +053069void GenericPipe::setPipeType(const utils::eMdpPipeType& pType) {
70 mCtrl->setPipeType(pType);
71}
72
Naseer Ahmed758bfc52012-11-28 17:02:08 -050073bool GenericPipe::commit() {
Saurabh Shah958051e2014-06-27 16:15:42 -070074 return mCtrl->commit();
Naseer Ahmed758bfc52012-11-28 17:02:08 -050075}
76
77bool GenericPipe::queueBuffer(int fd, uint32_t offset) {
Saurabh Shahd18d88a2014-01-06 15:02:49 -080078 int pipeId = mCtrl->getPipeId();
Naseer Ahmed758bfc52012-11-28 17:02:08 -050079 OVASSERT(-1 != pipeId, "Ctrl ID should not be -1");
80 // set pipe id from ctrl to data
Saurabh Shahd18d88a2014-01-06 15:02:49 -080081 mData->setPipeId(pipeId);
Naseer Ahmed758bfc52012-11-28 17:02:08 -050082
Saurabh Shahd18d88a2014-01-06 15:02:49 -080083 return mData->queueBuffer(fd, offset);
Naseer Ahmed758bfc52012-11-28 17:02:08 -050084}
85
Naseer Ahmed758bfc52012-11-28 17:02:08 -050086utils::Dim GenericPipe::getCrop() const
87{
Saurabh Shahd18d88a2014-01-06 15:02:49 -080088 return mCtrl->getCrop();
Naseer Ahmed758bfc52012-11-28 17:02:08 -050089}
90
Saurabh Shahdd8237a2014-02-28 14:29:09 -080091uint8_t GenericPipe::getPriority() const {
92 return mCtrl->getPriority();
93}
94
Naseer Ahmed758bfc52012-11-28 17:02:08 -050095void GenericPipe::dump() const
96{
97 ALOGE("== Dump Generic pipe start ==");
Saurabh Shahd18d88a2014-01-06 15:02:49 -080098 mCtrl->dump();
99 mData->dump();
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500100 ALOGE("== Dump Generic pipe end ==");
101}
102
Saurabh Shah0d0a7cb2013-02-12 17:58:19 -0800103void GenericPipe::getDump(char *buf, size_t len) {
Saurabh Shahd18d88a2014-01-06 15:02:49 -0800104 mCtrl->getDump(buf, len);
105 mData->getDump(buf, len);
Saurabh Shah0d0a7cb2013-02-12 17:58:19 -0800106}
107
Zohaib Alam4b0a9242013-11-20 23:54:12 -0500108int GenericPipe::getPipeId() {
Saurabh Shahd18d88a2014-01-06 15:02:49 -0800109 return mCtrl->getPipeId();
Zohaib Alam4b0a9242013-11-20 23:54:12 -0500110}
111
Saurabh Shaha36be922013-12-16 18:18:39 -0800112bool GenericPipe::validateAndSet(GenericPipe* pipeArray[], const int& count,
113 const int& fbFd) {
114 Ctrl* ctrlArray[count];
115 memset(&ctrlArray, 0, sizeof(ctrlArray));
116
117 for(int i = 0; i < count; i++) {
118 ctrlArray[i] = pipeArray[i]->mCtrl;
119 }
120
121 return Ctrl::validateAndSet(ctrlArray, count, fbFd);
122}
123
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500124} //namespace overlay