1 /* Copyright (c) 2012-2015, The Linux Foundataion. All rights reserved. 2 * 3 * Redistribution and use in source and binary forms, with or without 4 * modification, are permitted provided that the following conditions are 5 * met: 6 * * Redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer. 8 * * Redistributions in binary form must reproduce the above 9 * copyright notice, this list of conditions and the following 10 * disclaimer in the documentation and/or other materials provided 11 * with the distribution. 12 * * Neither the name of The Linux Foundation nor the names of its 13 * contributors may be used to endorse or promote products derived 14 * from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 */ 29 30 #ifndef __QCAMERA_CHANNEL_H__ 31 #define __QCAMERA_CHANNEL_H__ 32 33 #include <hardware/camera.h> 34 #include "QCameraStream.h" 35 36 extern "C" { 37 #include <mm_camera_interface.h> 38 } 39 40 namespace qcamera { 41 42 class QCameraChannel 43 { 44 public: 45 QCameraChannel(uint32_t cam_handle, 46 mm_camera_ops_t *cam_ops); 47 QCameraChannel(); 48 virtual ~QCameraChannel(); 49 virtual int32_t init(mm_camera_channel_attr_t *attr, 50 mm_camera_buf_notify_t dataCB, // data CB for channel data 51 void *userData); 52 // Owner of memory is transferred from the caller to the caller with this call. 53 virtual int32_t addStream(QCameraAllocator& allocator, 54 QCameraHeapMemory *streamInfoBuf, QCameraHeapMemory *miscBuf, 55 uint8_t minStreamBufnum, cam_padding_info_t *paddingInfo, 56 stream_cb_routine stream_cb, void *userdata, bool bDynAllocBuf, 57 bool bDeffAlloc = false, cam_rotation_t online_rotation = ROTATE_0); 58 virtual int32_t linkStream(QCameraChannel *ch, QCameraStream *stream); 59 virtual int32_t start(); 60 virtual int32_t stop(); 61 virtual int32_t bufDone(mm_camera_super_buf_t *recvd_frame); 62 virtual int32_t processZoomDone(preview_stream_ops_t *previewWindow, 63 cam_crop_data_t &crop_info); 64 int32_t config(); 65 QCameraStream *getStreamByHandle(uint32_t streamHandle); getMyHandle()66 uint32_t getMyHandle() const {return m_handle;}; getNumOfStreams()67 uint32_t getNumOfStreams() const {return (uint32_t) mStreams.size();}; 68 QCameraStream *getStreamByIndex(uint32_t index); 69 QCameraStream *getStreamByServerID(uint32_t serverID); 70 int32_t UpdateStreamBasedParameters(QCameraParameters ¶m); 71 void deleteChannel(); 72 73 protected: 74 uint32_t m_camHandle; 75 mm_camera_ops_t *m_camOps; 76 bool m_bIsActive; 77 bool m_bAllowDynBufAlloc; // if buf allocation can be in two steps 78 79 uint32_t m_handle; 80 Vector<QCameraStream *> mStreams; 81 mm_camera_buf_notify_t mDataCB; 82 void *mUserData; 83 }; 84 85 // burst pic channel: i.e. zsl burst mode 86 class QCameraPicChannel : public QCameraChannel 87 { 88 public: 89 QCameraPicChannel(uint32_t cam_handle, 90 mm_camera_ops_t *cam_ops); 91 QCameraPicChannel(); 92 virtual ~QCameraPicChannel(); 93 int32_t takePicture(uint8_t num_of_snapshot, uint8_t num_of_retro_snapshot); 94 int32_t cancelPicture(); 95 int32_t stopAdvancedCapture(mm_camera_advanced_capture_t type); 96 int32_t startAdvancedCapture(mm_camera_advanced_capture_t type, 97 cam_capture_frame_config_t *config = NULL); 98 int32_t flushSuperbuffer(uint32_t frame_idx); 99 }; 100 101 // video channel class 102 class QCameraVideoChannel : public QCameraChannel 103 { 104 public: 105 QCameraVideoChannel(uint32_t cam_handle, 106 mm_camera_ops_t *cam_ops); 107 QCameraVideoChannel(); 108 virtual ~QCameraVideoChannel(); 109 int32_t releaseFrame(const void *opaque, bool isMetaData); 110 }; 111 112 // reprocess channel class 113 class QCameraReprocessChannel : public QCameraChannel 114 { 115 public: 116 QCameraReprocessChannel(uint32_t cam_handle, 117 mm_camera_ops_t *cam_ops); 118 QCameraReprocessChannel(); 119 virtual ~QCameraReprocessChannel(); 120 int32_t addReprocStreamsFromSource(QCameraAllocator& allocator, 121 cam_pp_feature_config_t &config, 122 QCameraChannel *pSrcChannel, 123 uint8_t minStreamBufNum, 124 uint8_t burstNum, 125 cam_padding_info_t *paddingInfo, 126 QCameraParameters ¶m, 127 bool contStream, 128 bool offline); 129 // online reprocess 130 int32_t doReprocess(mm_camera_super_buf_t *frame, 131 QCameraParameters ¶m, QCameraStream *pMetaStream, 132 uint8_t meta_buf_index); 133 134 // offline reprocess 135 int32_t doReprocess(int buf_fd, size_t buf_length, int32_t &ret_val); 136 137 int32_t doReprocessOffline(mm_camera_super_buf_t *frame, 138 mm_camera_buf_def_t *meta_buf); 139 140 int32_t stop(); getSrcChannel()141 QCameraChannel *getSrcChannel(){return m_pSrcChannel;}; 142 143 private: 144 QCameraStream *getStreamBySrouceHandle(uint32_t srcHandle); 145 146 typedef struct { 147 QCameraStream *stream; 148 cam_mapping_buf_type type; 149 uint32_t index; 150 } OfflineBuffer; 151 152 uint32_t mSrcStreamHandles[MAX_STREAM_NUM_IN_BUNDLE]; 153 QCameraChannel *m_pSrcChannel; // ptr to source channel for reprocess 154 android::List<OfflineBuffer> mOfflineBuffers; 155 156 }; 157 158 }; // namespace qcamera 159 160 #endif /* __QCAMERA_CHANNEL_H__ */ 161