Home | History | Annotate | Download | only in inc
      1 /*
      2 ** Copyright (c) 2011-2012 The Linux Foundation. All rights reserved.
      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 
     17 
     18 #ifndef __QCAMERAHWI_MEM_H
     19 #define __QCAMERAHWI_MEM_H
     20 
     21 #include <binder/MemoryBase.h>
     22 #include <binder/MemoryHeapBase.h>
     23 #include <utils/threads.h>
     24 #include <stdint.h>
     25 
     26 extern "C" {
     27 #include <linux/android_pmem.h>
     28 #include <linux/ion.h>
     29 #include <camera_defs_i.h>
     30 
     31 }
     32 
     33 
     34 #define VIDEO_BUFFER_COUNT 5
     35 #define VIDEO_BUFFER_COUNT_LOW_POWER_CAMCORDER 9
     36 
     37 #define PREVIEW_BUFFER_COUNT 5
     38 
     39 namespace android {
     40 
     41 // This class represents a heap which maintains several contiguous
     42 // buffers.  The heap may be backed by pmem (when pmem_pool contains
     43 // the name of a /dev/pmem* file), or by ashmem (when pmem_pool == NULL).
     44 
     45 struct MemPool : public RefBase {
     46     MemPool(int buffer_size, int num_buffers,
     47             int frame_size,
     48             const char *name);
     49 
     50     virtual ~MemPool() = 0;
     51 
     52     void completeInitialization();
     53     bool initialized() const {
     54         return mHeap != NULL && mHeap->base() != MAP_FAILED;
     55     }
     56 
     57     virtual status_t dump(int fd, const Vector<String16>& args) const;
     58 
     59     int mBufferSize;
     60     int mAlignedBufferSize;
     61     int mNumBuffers;
     62     int mFrameSize;
     63     sp<MemoryHeapBase> mHeap;
     64     sp<MemoryBase> *mBuffers;
     65 
     66     const char *mName;
     67 };
     68 
     69 class AshmemPool : public MemPool {
     70 public:
     71     AshmemPool(int buffer_size, int num_buffers,
     72                int frame_size,
     73                const char *name);
     74 };
     75 
     76 class PmemPool : public MemPool {
     77 public:
     78     PmemPool(const char *pmem_pool,
     79              int flags, int pmem_type,
     80              int buffer_size, int num_buffers,
     81              int frame_size, int cbcr_offset,
     82              int yoffset, const char *name);
     83     virtual ~PmemPool();
     84     int mFd;
     85     int mPmemType;
     86     int mCbCrOffset;
     87     int myOffset;
     88     int mCameraControlFd;
     89     uint32_t mAlignedSize;
     90     struct pmem_region mSize;
     91 };
     92 
     93 class IonPool : public MemPool {
     94 public:
     95     IonPool( int flags,
     96              int buffer_size, int num_buffers,
     97              int frame_size, int cbcr_offset,
     98              int yoffset, const char *name);
     99     virtual ~IonPool();
    100     int mFd;
    101     int mCbCrOffset;
    102     int myOffset;
    103     int mCameraControlFd;
    104     uint32_t mAlignedSize;
    105 private:
    106     static const char mIonDevName[];
    107 };
    108 
    109 };
    110 #endif
    111