blob: 2cbf1c57cf3dbbfc1bd37f5975d37a7ee648cd58 [file] [log] [blame]
Naseer Ahmed29a26812012-06-14 00:56:20 -07001/*
2* Copyright (C) 2008 The Android Open Source Project
Saurabh Shah56f610d2012-08-07 15:27:06 -07003* Copyright (c) 2010-2012, The Linux Foundation. All rights reserved.
Naseer Ahmed29a26812012-06-14 00:56:20 -07004*
5* Licensed under the Apache License, Version 2.0 (the "License");
6* you may not use this file except in compliance with the License.
7* You may obtain a copy of the License at
8*
9* http://www.apache.org/licenses/LICENSE-2.0
10*
11* Unless required by applicable law or agreed to in writing, software
12* distributed under the License is distributed on an "AS IS" BASIS,
13* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14* See the License for the specific language governing permissions and
15* limitations under the License.
16*/
17
18#include <cutils/properties.h>
19#include "overlayCtrlData.h"
20#include "fb_priv.h"
Naseer Ahmedf48aef62012-07-20 09:05:53 -070021#include "gralloc_priv.h" //for interlace
Naseer Ahmed29a26812012-06-14 00:56:20 -070022
23namespace overlay{
24
Naseer Ahmedf48aef62012-07-20 09:05:53 -070025bool Ctrl::init(uint32_t fbnum) {
26 // MDP/FD init
27 if(!mMdp.init(fbnum)) {
28 ALOGE("Ctrl failed to init fbnum=%d", fbnum);
Naseer Ahmed29a26812012-06-14 00:56:20 -070029 return false;
30 }
31
32 if(!getScreenInfo(mInfo)) {
33 ALOGE("Ctrl failed to getScreenInfo");
34 return false;
35 }
36
Naseer Ahmed29a26812012-06-14 00:56:20 -070037 return true;
38}
39
Naseer Ahmed29a26812012-06-14 00:56:20 -070040bool Ctrl::setSource(const utils::PipeArgs& args)
41{
Naseer Ahmedf48aef62012-07-20 09:05:53 -070042 return mMdp.setSource(args);
Naseer Ahmed29a26812012-06-14 00:56:20 -070043}
44
45bool Ctrl::setPosition(const utils::Dim& dim)
46{
47 if(!dim.check(mInfo.mFBWidth, mInfo.mFBHeight)) {
48 ALOGE("Ctrl setPosition error in dim");
49 dim.dump();
50 return false;
51 }
52
53 if(!mMdp.setPosition(dim, mInfo.mFBWidth, mInfo.mFBHeight)) {
54 ALOGE("Ctrl failed MDP setPosition");
55 return false;
56 }
57 return true;
58}
59
Ramkumar Radhakrishnan288f8c72013-01-15 11:37:54 -080060bool Ctrl::setTransform(const utils::eTransform& orient)
Naseer Ahmed29a26812012-06-14 00:56:20 -070061{
Ramkumar Radhakrishnan288f8c72013-01-15 11:37:54 -080062 if(!mMdp.setTransform(orient)) {
Naseer Ahmedf48aef62012-07-20 09:05:53 -070063 ALOGE("Ctrl setTransform failed for Mdp");
64 return false;
Naseer Ahmed29a26812012-06-14 00:56:20 -070065 }
66 return true;
67}
68
Ramkumar Radhakrishnan288f8c72013-01-15 11:37:54 -080069void Ctrl::setRotatorUsed(const bool& rotUsed) {
70 mMdp.setRotatorUsed(rotUsed);
71}
72
Naseer Ahmed29a26812012-06-14 00:56:20 -070073bool Ctrl::setCrop(const utils::Dim& d)
74{
Naseer Ahmed29a26812012-06-14 00:56:20 -070075 if(!mMdp.setCrop(d)) {
76 ALOGE("Data setCrop failed in MDP setCrop");
77 return false;
78 }
Naseer Ahmed29a26812012-06-14 00:56:20 -070079 return true;
80}
81
Naseer Ahmed29a26812012-06-14 00:56:20 -070082utils::FrameBufferInfo* utils::FrameBufferInfo::sFBInfoInstance = 0;
83
Naseer Ahmed29a26812012-06-14 00:56:20 -070084void Ctrl::dump() const {
85 ALOGE("== Dump Ctrl start ==");
Naseer Ahmed29a26812012-06-14 00:56:20 -070086 mInfo.dump("mInfo");
87 mMdp.dump();
Naseer Ahmed29a26812012-06-14 00:56:20 -070088 ALOGE("== Dump Ctrl end ==");
89}
90
91} // overlay