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