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 <common/utils/HwcTrace.h>
17 #include <platforms/merrifield_plus/PlatfBufferManager.h>
18 #include <ips/tangier/TngGrallocBuffer.h>
19 #include <ips/tangier/TngGrallocBufferMapper.h>
20 #include <sync/sync.h>
21 
22 namespace android {
23 namespace intel {
24 
PlatfBufferManager()25 PlatfBufferManager::PlatfBufferManager()
26     : BufferManager()
27 {
28 
29 }
30 
~PlatfBufferManager()31 PlatfBufferManager::~PlatfBufferManager()
32 {
33 
34 }
35 
initialize()36 bool PlatfBufferManager::initialize()
37 {
38     return BufferManager::initialize();
39 }
40 
deinitialize()41 void PlatfBufferManager::deinitialize()
42 {
43     BufferManager::deinitialize();
44 }
45 
createDataBuffer(uint32_t handle)46 DataBuffer* PlatfBufferManager::createDataBuffer(uint32_t handle)
47 {
48     return new TngGrallocBuffer(handle);
49 }
50 
createBufferMapper(DataBuffer & buffer)51 BufferMapper* PlatfBufferManager::createBufferMapper(DataBuffer& buffer)
52 {
53     return new TngGrallocBufferMapper(*mGralloc, buffer);
54 }
55 
blitGrallocBuffer(uint32_t srcHandle,uint32_t dstHandle,crop_t & srcCrop,uint32_t async)56 bool PlatfBufferManager::blitGrallocBuffer(uint32_t srcHandle, uint32_t dstHandle,
57                                   crop_t& srcCrop, uint32_t async)
58 
59 {
60     int fenceFd;
61 
62     if (gralloc_blit_handle_to_handle_img(mGralloc,
63                                 (buffer_handle_t)srcHandle,
64                                 (buffer_handle_t)dstHandle,
65                                 srcCrop.w, srcCrop.h, srcCrop.x,
66                                 srcCrop.y, 0, -1, &fenceFd)) {
67         ELOGTRACE("Blit failed");
68         return false;
69     }
70 
71     if (!async) {
72         sync_wait(fenceFd, -1);
73     }
74     close(fenceFd);
75     return true;
76 }
77 
78 
79 } // namespace intel
80 } // namespace android
81