blob: 90a1e7a58f15c73f5d9b2f487cb35c52306abfc3 [file] [log] [blame]
Naseer Ahmed29a26812012-06-14 00:56:20 -07001/*
Naseer Ahmed758bfc52012-11-28 17:02:08 -05002 * Copyright (C) 2008 The Android Open Source Project
3 * Copyright (c) 2010-2012, The Linux Foundation. All rights reserved.
4 * Not a Contribution, Apache license notifications and license are retained
5 * for attribution purposes only.
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
Naseer Ahmed29a26812012-06-14 00:56:20 -070018*/
19
20#include "overlayRotator.h"
21#include "overlayUtils.h"
Saurabh Shahe012f7a2012-08-18 15:11:57 -070022#include "mdp_version.h"
Saurabh Shahfc3652f2013-02-15 13:15:45 -080023#include "gr.h"
Naseer Ahmed29a26812012-06-14 00:56:20 -070024
25namespace ovutils = overlay::utils;
26
27namespace overlay {
28
Naseer Ahmed758bfc52012-11-28 17:02:08 -050029Rotator::~Rotator() {}
30
31Rotator* Rotator::getRotator() {
32 int type = getRotatorHwType();
33 if(type == TYPE_MDP) {
34 return new MdpRot(); //will do reset
35 } else if(type == TYPE_MDSS) {
36 return new MdssRot();
37 } else {
38 ALOGE("%s Unknown h/w type %d", __FUNCTION__, type);
39 return NULL;
40 }
41}
42
Saurabh Shahfc3652f2013-02-15 13:15:45 -080043uint32_t Rotator::calcOutputBufSize(const utils::Whf& destWhf) {
44 //dummy aligned w & h.
45 int alW = 0, alH = 0;
46 int halFormat = ovutils::getHALFormat(destWhf.format);
47 //A call into gralloc/memalloc
48 return getBufferSizeAndDimensions(
49 destWhf.w, destWhf.h, halFormat, alW, alH);
50}
51
Naseer Ahmed758bfc52012-11-28 17:02:08 -050052int Rotator::getRotatorHwType() {
Saurabh Shahe012f7a2012-08-18 15:11:57 -070053 int mdpVersion = qdutils::MDPVersion::getInstance().getMDPVersion();
54 if (mdpVersion == qdutils::MDSS_V5)
55 return TYPE_MDSS;
Naseer Ahmedf48aef62012-07-20 09:05:53 -070056 return TYPE_MDP;
Naseer Ahmed29a26812012-06-14 00:56:20 -070057}
58
Naseer Ahmedf48aef62012-07-20 09:05:53 -070059bool RotMem::close() {
60 bool ret = true;
61 for(uint32_t i=0; i < RotMem::MAX_ROT_MEM; ++i) {
62 // skip current, and if valid, close
63 if(m[i].valid()) {
64 if(m[i].close() == false) {
65 ALOGE("%s error in closing rot mem %d", __FUNCTION__, i);
66 ret = false;
67 }
68 }
Naseer Ahmed29a26812012-06-14 00:56:20 -070069 }
Naseer Ahmedf48aef62012-07-20 09:05:53 -070070 return ret;
Naseer Ahmed29a26812012-06-14 00:56:20 -070071}
72
Naseer Ahmed29a26812012-06-14 00:56:20 -070073}