QCamera3Stream.h revision 625515beb9c1347216a2d261930ceb0d85ba1c47
1/* Copyright (c) 2012-2013, 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 __QCAMERA3_STREAM_H__ 31#define __QCAMERA3_STREAM_H__ 32 33#include <hardware/camera3.h> 34#include "QCameraCmdThread.h" 35#include "QCamera3Mem.h" 36 37extern "C" { 38#include <mm_camera_interface.h> 39} 40 41namespace qcamera { 42 43class QCamera3Stream; 44typedef void (*stream_cb_routine)(mm_camera_super_buf_t *frame, 45 QCamera3Stream *stream, 46 void *userdata); 47 48class QCamera3Stream 49{ 50public: 51 QCamera3Stream(uint32_t camHandle, 52 uint32_t chId, 53 mm_camera_ops_t *camOps, 54 cam_padding_info_t *paddingInfo, 55 QCamera3Memory *memory); 56 virtual ~QCamera3Stream(); 57 virtual int32_t init(cam_stream_type_t streamType, 58 cam_format_t streamFormat, 59 cam_dimension_t streamDim, 60 uint8_t minStreamBufNum, 61 stream_cb_routine stream_cb, 62 void *userdata); 63 virtual int32_t bufDone(int index); 64 virtual int32_t bufDone(const void *opaque, bool isMetaData); 65 virtual int32_t processDataNotify(mm_camera_super_buf_t *bufs); 66 virtual int32_t start(); 67 virtual int32_t stop(); 68 69 static void dataNotifyCB(mm_camera_super_buf_t *recvd_frame, void *userdata); 70 static void *dataProcRoutine(void *data); 71 uint32_t getMyHandle() const {return mHandle;} 72 bool isTypeOf(cam_stream_type_t type); 73 int32_t getFrameOffset(cam_frame_len_offset_t &offset); 74 int32_t getFrameDimension(cam_dimension_t &dim); 75 int32_t getFormat(cam_format_t &fmt); 76 QCamera3Memory *getStreamBufs() {return mStreamBufs;}; 77 uint32_t getMyServerID(); 78 79 int32_t mapBuf(uint8_t buf_type, uint32_t buf_idx, 80 int32_t plane_idx, int fd, uint32_t size); 81 int32_t unmapBuf(uint8_t buf_type, uint32_t buf_idx, int32_t plane_idx); 82 int32_t setParameter(cam_stream_parm_buffer_t ¶m); 83 84private: 85 uint32_t mCamHandle; 86 uint32_t mChannelHandle; 87 uint32_t mHandle; // stream handle from mm-camera-interface 88 mm_camera_ops_t *mCamOps; 89 cam_stream_info_t *mStreamInfo; // ptr to stream info buf 90 mm_camera_stream_mem_vtbl_t mMemVtbl; 91 uint8_t mNumBufs; 92 stream_cb_routine mDataCB; 93 void *mUserData; 94 95 QCameraQueue mDataQ; 96 QCameraCmdThread mProcTh; // thread for dataCB 97 98 QCamera3HeapMemory *mStreamInfoBuf; 99 QCamera3Memory *mStreamBufs; 100 mm_camera_buf_def_t *mBufDefs; 101 cam_frame_len_offset_t mFrameLenOffset; 102 cam_padding_info_t mPaddingInfo; 103 104 static int32_t get_bufs( 105 cam_frame_len_offset_t *offset, 106 uint8_t *num_bufs, 107 uint8_t **initial_reg_flag, 108 mm_camera_buf_def_t **bufs, 109 mm_camera_map_unmap_ops_tbl_t *ops_tbl, 110 void *user_data); 111 static int32_t put_bufs( 112 mm_camera_map_unmap_ops_tbl_t *ops_tbl, 113 void *user_data); 114 115 int32_t getBufs(cam_frame_len_offset_t *offset, 116 uint8_t *num_bufs, 117 uint8_t **initial_reg_flag, 118 mm_camera_buf_def_t **bufs, 119 mm_camera_map_unmap_ops_tbl_t *ops_tbl); 120 int32_t putBufs(mm_camera_map_unmap_ops_tbl_t *ops_tbl); 121 122}; 123 124}; // namespace qcamera 125 126#endif /* __QCAMERA3_STREAM_H__ */ 127