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