16a6081a46a83da606cf21548879b37695adc7e1fAndy Qiu/*
2cd727f537d5085eec7f1b8f9c1d33922d4de75d4Prodyut Hazarika// Copyright (c) 2014 Intel Corporation 
3cd727f537d5085eec7f1b8f9c1d33922d4de75d4Prodyut Hazarika//
4cd727f537d5085eec7f1b8f9c1d33922d4de75d4Prodyut Hazarika// Licensed under the Apache License, Version 2.0 (the "License");
5cd727f537d5085eec7f1b8f9c1d33922d4de75d4Prodyut Hazarika// you may not use this file except in compliance with the License.
6cd727f537d5085eec7f1b8f9c1d33922d4de75d4Prodyut Hazarika// You may obtain a copy of the License at
7cd727f537d5085eec7f1b8f9c1d33922d4de75d4Prodyut Hazarika//
8cd727f537d5085eec7f1b8f9c1d33922d4de75d4Prodyut Hazarika//      http://www.apache.org/licenses/LICENSE-2.0
9cd727f537d5085eec7f1b8f9c1d33922d4de75d4Prodyut Hazarika//
10cd727f537d5085eec7f1b8f9c1d33922d4de75d4Prodyut Hazarika// Unless required by applicable law or agreed to in writing, software
11cd727f537d5085eec7f1b8f9c1d33922d4de75d4Prodyut Hazarika// distributed under the License is distributed on an "AS IS" BASIS,
12cd727f537d5085eec7f1b8f9c1d33922d4de75d4Prodyut Hazarika// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13cd727f537d5085eec7f1b8f9c1d33922d4de75d4Prodyut Hazarika// See the License for the specific language governing permissions and
14cd727f537d5085eec7f1b8f9c1d33922d4de75d4Prodyut Hazarika// limitations under the License.
15cd727f537d5085eec7f1b8f9c1d33922d4de75d4Prodyut Hazarika*/
160594c42af26255fd8d3d7d39c0cb0e2da5b8841bThierry Strudel#include <common/utils/HwcTrace.h>
170594c42af26255fd8d3d7d39c0cb0e2da5b8841bThierry Strudel#include <ips/tangier/TngGrallocBuffer.h>
18ca4b950d7e25063c8ffc3160b60b6e86a2ec5503Austin Hu#include <khronos/openmax/OMX_IntelVideoExt.h>
196a6081a46a83da606cf21548879b37695adc7e1fAndy Qiu
206a6081a46a83da606cf21548879b37695adc7e1fAndy Qiunamespace android {
216a6081a46a83da606cf21548879b37695adc7e1fAndy Qiunamespace intel {
226a6081a46a83da606cf21548879b37695adc7e1fAndy Qiu
236a6081a46a83da606cf21548879b37695adc7e1fAndy QiuTngGrallocBuffer::TngGrallocBuffer(uint32_t handle)
24e6ecdadd57e79c2218b3e6ae407f12599f33bd22Jackie Li    :GrallocBufferBase(handle)
256a6081a46a83da606cf21548879b37695adc7e1fAndy Qiu{
26eb726af21649d79ed720bdf329e0849270995c45Andy Qiu    initBuffer(handle);
27eb726af21649d79ed720bdf329e0849270995c45Andy Qiu}
28eb726af21649d79ed720bdf329e0849270995c45Andy Qiu
29eb726af21649d79ed720bdf329e0849270995c45Andy QiuTngGrallocBuffer::~TngGrallocBuffer()
30eb726af21649d79ed720bdf329e0849270995c45Andy Qiu{
31eb726af21649d79ed720bdf329e0849270995c45Andy Qiu}
32eb726af21649d79ed720bdf329e0849270995c45Andy Qiu
33eb726af21649d79ed720bdf329e0849270995c45Andy Qiuvoid TngGrallocBuffer::resetBuffer(uint32_t handle)
34eb726af21649d79ed720bdf329e0849270995c45Andy Qiu{
35eb726af21649d79ed720bdf329e0849270995c45Andy Qiu    GrallocBufferBase::resetBuffer(handle);
36eb726af21649d79ed720bdf329e0849270995c45Andy Qiu    initBuffer(handle);
37eb726af21649d79ed720bdf329e0849270995c45Andy Qiu}
38eb726af21649d79ed720bdf329e0849270995c45Andy Qiu
39eb726af21649d79ed720bdf329e0849270995c45Andy Qiuvoid TngGrallocBuffer::initBuffer(uint32_t handle)
40eb726af21649d79ed720bdf329e0849270995c45Andy Qiu{
41998f109c19fc9d5af0e4611739e0d635da484d93Jackie Li    TngIMGGrallocBuffer *grallocHandle = (TngIMGGrallocBuffer *)handle;
426a6081a46a83da606cf21548879b37695adc7e1fAndy Qiu
43e2b2a5fe291662041d1bbec00996c2ba302dc4c9Andy Qiu    CTRACE();
446a6081a46a83da606cf21548879b37695adc7e1fAndy Qiu
45e2b2a5fe291662041d1bbec00996c2ba302dc4c9Andy Qiu    if (!grallocHandle) {
464157ee3f6fb20e0a249b9eedc06f3b16785ba31bIliyan Malchev        ELOGTRACE("gralloc handle is null");
47e6ecdadd57e79c2218b3e6ae407f12599f33bd22Jackie Li        return;
48e2b2a5fe291662041d1bbec00996c2ba302dc4c9Andy Qiu    }
496a6081a46a83da606cf21548879b37695adc7e1fAndy Qiu
50998f109c19fc9d5af0e4611739e0d635da484d93Jackie Li    mFormat = grallocHandle->iFormat;
51ca4b950d7e25063c8ffc3160b60b6e86a2ec5503Austin Hu    if (mFormat == OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar ||
52ca4b950d7e25063c8ffc3160b60b6e86a2ec5503Austin Hu        mFormat == OMX_INTEL_COLOR_FormatYUV420PackedSemiPlanar_Tiled) {
53ca4b950d7e25063c8ffc3160b60b6e86a2ec5503Austin Hu        mWidth = grallocHandle->aiStride[0];
54ca4b950d7e25063c8ffc3160b60b6e86a2ec5503Austin Hu    } else
55ca4b950d7e25063c8ffc3160b60b6e86a2ec5503Austin Hu        mWidth = grallocHandle->iWidth;
56998f109c19fc9d5af0e4611739e0d635da484d93Jackie Li    mHeight = grallocHandle->iHeight;
576a6081a46a83da606cf21548879b37695adc7e1fAndy Qiu    mUsage = grallocHandle->usage;
586a6081a46a83da606cf21548879b37695adc7e1fAndy Qiu    mKey = grallocHandle->ui64Stamp;
59998f109c19fc9d5af0e4611739e0d635da484d93Jackie Li    mBpp = grallocHandle->uiBpp;
606a6081a46a83da606cf21548879b37695adc7e1fAndy Qiu
61eb726af21649d79ed720bdf329e0849270995c45Andy Qiu    // stride can only be initialized after format is set
62eb726af21649d79ed720bdf329e0849270995c45Andy Qiu    initStride();
636a6081a46a83da606cf21548879b37695adc7e1fAndy Qiu}
646a6081a46a83da606cf21548879b37695adc7e1fAndy Qiu
65eb726af21649d79ed720bdf329e0849270995c45Andy Qiu
666a6081a46a83da606cf21548879b37695adc7e1fAndy Qiu}
676a6081a46a83da606cf21548879b37695adc7e1fAndy Qiu}
68