Home | History | Annotate | Download | only in merrifield_plus
      1 /*
      2 // Copyright(c)2014 IntelCorporation
      3 //
      4 // LicensedundertheApacheLicense,Version2.0(the"License");
      5 // youmaynotusethisfileexceptincompliancewiththeLicense.
      6 // YoumayobtainacopyoftheLicenseat
      7 //
      8 // http://www.apache.org/licenses/LICENSE-2.0
      9 //
     10 // Unlessrequiredbyapplicablelaworagreedtoinwriting,software
     11 // distributedundertheLicenseisdistributedonan"ASIS"BASIS,
     12 // WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied.
     13 // SeetheLicenseforthespecificlanguagegoverningpermissionsand
     14 // limitationsundertheLicense.
     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 
     25 PlatfBufferManager::PlatfBufferManager()
     26     : BufferManager()
     27 {
     28 
     29 }
     30 
     31 PlatfBufferManager::~PlatfBufferManager()
     32 {
     33 
     34 }
     35 
     36 bool PlatfBufferManager::initialize()
     37 {
     38     return BufferManager::initialize();
     39 }
     40 
     41 void PlatfBufferManager::deinitialize()
     42 {
     43     BufferManager::deinitialize();
     44 }
     45 
     46 DataBuffer* PlatfBufferManager::createDataBuffer(gralloc_module_t * /* module */,
     47         uint32_t handle)
     48 {
     49     return new TngGrallocBuffer(handle);
     50 }
     51 
     52 BufferMapper* PlatfBufferManager::createBufferMapper(gralloc_module_t *module,
     53                                                         DataBuffer& buffer)
     54 {
     55     if (!module)
     56         return 0;
     57 
     58     return new TngGrallocBufferMapper(*(IMG_gralloc_module_public_t*)module,
     59                                         buffer);
     60 }
     61 
     62 bool PlatfBufferManager::blitGrallocBuffer(uint32_t srcHandle, uint32_t dstHandle,
     63                                   crop_t& srcCrop, uint32_t async)
     64 
     65 {
     66     IMG_gralloc_module_public_t *imgGrallocModule = (IMG_gralloc_module_public_t *) mGrallocModule;
     67     int fenceFd;
     68 
     69     if (imgGrallocModule->Blit(imgGrallocModule, (buffer_handle_t)srcHandle,
     70                                 (buffer_handle_t)dstHandle,
     71                                 srcCrop.w, srcCrop.h, srcCrop.x,
     72                                 srcCrop.y, 0, -1, &fenceFd)) {
     73         ELOGTRACE("Blit failed");
     74         return false;
     75     }
     76 
     77     if (!async) {
     78         sync_wait(fenceFd, -1);
     79     }
     80     close(fenceFd);
     81     return true;
     82 }
     83 
     84 
     85 } // namespace intel
     86 } // namespace android
     87