Home | History | Annotate | Download | only in inc
      1 /*
      2 ** Copyright (c) 2012 The Linux Foundation. All rights reserved.
      3 **
      4 ** Not a Contribution, Apache license notifications and license are retained
      5 ** for attribution purposes only.
      6 **
      7 ** Licensed under the Apache License, Version 2.0 (the "License");
      8 ** you may not use this file except in compliance with the License.
      9 ** You may obtain a copy of the License at
     10 **
     11 **     http://www.apache.org/licenses/LICENSE-2.0
     12 **
     13 ** Unless required by applicable law or agreed to in writing, software
     14 ** distributed under the License is distributed on an "AS IS" BASIS,
     15 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16 ** See the License for the specific language governing permissions and
     17 ** limitations under the License.
     18 */
     19 
     20 
     21 #ifndef __QCAMERAHWI_MEM_H
     22 #define __QCAMERAHWI_MEM_H
     23 
     24 #include <binder/MemoryBase.h>
     25 #include <binder/MemoryHeapBase.h>
     26 #include <utils/threads.h>
     27 #include <stdint.h>
     28 
     29 extern "C" {
     30 #include <linux/android_pmem.h>
     31 #include <linux/msm_ion.h>
     32 }
     33 
     34 #define VIDEO_BUFFER_COUNT NUM_RECORDING_BUFFERS
     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