1/*
2// Copyright (c) 2014 Intel Corporation 
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//      http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15*/
16#include <HwcTrace.h>
17#include <Drm.h>
18#include <Hwcomposer.h>
19#include <common/GrallocBufferMapperBase.h>
20
21namespace android {
22namespace intel {
23
24GrallocBufferMapperBase::GrallocBufferMapperBase(DataBuffer& buffer)
25    : BufferMapper(buffer)
26{
27    CTRACE();
28
29    for (int i = 0; i < SUB_BUFFER_MAX; i++) {
30        mGttOffsetInPage[i] = 0;
31        mCpuAddress[i] = 0;
32        mSize[i] = 0;
33        mKHandle[i] = 0;
34    }
35}
36
37GrallocBufferMapperBase::~GrallocBufferMapperBase()
38{
39    CTRACE();
40}
41
42uint32_t GrallocBufferMapperBase::getGttOffsetInPage(int subIndex) const
43{
44    if (subIndex >= 0 && subIndex < SUB_BUFFER_MAX)
45        return mGttOffsetInPage[subIndex];
46    return 0;
47}
48
49void* GrallocBufferMapperBase::getCpuAddress(int subIndex) const
50{
51    if (subIndex >=0 && subIndex < SUB_BUFFER_MAX)
52        return mCpuAddress[subIndex];
53    return 0;
54}
55
56uint32_t GrallocBufferMapperBase::getSize(int subIndex) const
57{
58    if (subIndex >= 0 && subIndex < SUB_BUFFER_MAX)
59        return mSize[subIndex];
60    return 0;
61}
62
63buffer_handle_t GrallocBufferMapperBase::getKHandle(int subIndex)
64{
65    if (subIndex >= 0 && subIndex < SUB_BUFFER_MAX)
66        return mKHandle[subIndex];
67    return 0;
68}
69
70
71} // namespace intel
72} // namespace android
73