1 /* Copyright (c) 2012-2016, The Linux Foundation. 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_CHANNEL_H__ 31 #define __QCAMERA3_CHANNEL_H__ 32 33 // System dependencies 34 #include <utils/List.h> 35 #include <utils/Mutex.h> 36 #include <utils/Vector.h> 37 #include "gralloc_priv.h" 38 39 // Camera dependencies 40 #include "cam_intf.h" 41 #include "cam_types.h" 42 #include "camera3.h" 43 #include "QCamera3HALHeader.h" 44 #include "QCamera3Mem.h" 45 #include "QCamera3PostProc.h" 46 #include "QCamera3Stream.h" 47 #include "QCamera3StreamMem.h" 48 49 extern "C" { 50 #include "mm_camera_interface.h" 51 #include "mm_jpeg_interface.h" 52 } 53 54 using namespace android; 55 56 #define MIN_STREAMING_BUFFER_NUM 7+11 57 58 #define QCAMERA_DUMP_FRM_PREVIEW 1 59 #define QCAMERA_DUMP_FRM_VIDEO (1<<1) 60 #define QCAMERA_DUMP_FRM_SNAPSHOT (1<<2) 61 #define QCAMERA_DUMP_FRM_CALLBACK (1<<3) 62 #define QCAMERA_DUMP_FRM_INPUT_REPROCESS (1<<6) 63 64 typedef int64_t nsecs_t; 65 66 namespace qcamera { 67 68 typedef void (*channel_cb_routine)(mm_camera_super_buf_t *metadata, 69 camera3_stream_buffer_t *buffer, 70 uint32_t frame_number, bool isInputBuffer, 71 void *userdata); 72 class QCamera3Channel 73 { 74 public: 75 QCamera3Channel(uint32_t cam_handle, 76 uint32_t channel_handle, 77 mm_camera_ops_t *cam_ops, 78 channel_cb_routine cb_routine, 79 cam_padding_info_t *paddingInfo, 80 uint32_t postprocess_mask, 81 void *userData, uint32_t numBuffers); 82 virtual ~QCamera3Channel(); 83 84 virtual int32_t start(); 85 virtual int32_t stop(); 86 virtual int32_t setBatchSize(uint32_t); 87 virtual int32_t queueBatchBuf(); 88 virtual int32_t setPerFrameMapUnmap(bool enable); 89 int32_t bufDone(mm_camera_super_buf_t *recvd_frame); 90 int32_t setBundleInfo(const cam_bundle_config_t &bundleInfo); 91 92 virtual uint32_t getStreamTypeMask(); 93 uint32_t getStreamID(uint32_t streamMask); 94 void destroy(); 95 virtual int32_t initialize(cam_is_type_t isType) = 0; request(buffer_handle_t *,uint32_t)96 virtual int32_t request(buffer_handle_t * /*buffer*/, 97 uint32_t /*frameNumber*/){ return 0;}; request(buffer_handle_t *,uint32_t,camera3_stream_buffer_t *,metadata_buffer_t *)98 virtual int32_t request(buffer_handle_t * /*buffer*/, 99 uint32_t /*frameNumber*/, 100 camera3_stream_buffer_t* /*pInputBuffer*/, 101 metadata_buffer_t* /*metadata*/){ return 0;}; 102 virtual void streamCbRoutine(mm_camera_super_buf_t *super_frame, 103 QCamera3Stream *stream) = 0; 104 105 virtual int32_t registerBuffer(buffer_handle_t *buffer, cam_is_type_t isType) = 0; 106 virtual QCamera3StreamMem *getStreamBufs(uint32_t len) = 0; 107 virtual void putStreamBufs() = 0; 108 virtual int32_t flush(); 109 110 QCamera3Stream *getStreamByHandle(uint32_t streamHandle); getMyHandle()111 uint32_t getMyHandle() const {return m_handle;}; getNumOfStreams()112 uint32_t getNumOfStreams() const {return m_numStreams;}; getNumBuffers()113 uint32_t getNumBuffers() const {return mNumBuffers;}; 114 QCamera3Stream *getStreamByIndex(uint32_t index); 115 116 static void streamCbRoutine(mm_camera_super_buf_t *super_frame, 117 QCamera3Stream *stream, void *userdata); 118 void dumpYUV(mm_camera_buf_def_t *frame, cam_dimension_t dim, 119 cam_frame_len_offset_t offset, uint8_t name); 120 bool isUBWCEnabled(); 121 cam_format_t getStreamDefaultFormat(cam_stream_type_t type); 122 123 void *mUserData; 124 cam_padding_info_t mPaddingInfo; 125 QCamera3Stream *mStreams[MAX_STREAM_NUM_IN_BUNDLE]; 126 uint32_t m_numStreams; 127 protected: 128 129 int32_t addStream(cam_stream_type_t streamType, 130 cam_format_t streamFormat, 131 cam_dimension_t streamDim, 132 cam_rotation_t streamRotation, 133 uint8_t minStreamBufnum, 134 uint32_t postprocessMask, 135 cam_is_type_t isType, 136 uint32_t batchSize = 0); 137 138 int32_t allocateStreamInfoBuf(camera3_stream_t *stream); 139 140 uint32_t m_camHandle; 141 mm_camera_ops_t *m_camOps; 142 bool m_bIsActive; 143 144 uint32_t m_handle; 145 146 147 mm_camera_buf_notify_t mDataCB; 148 149 150 QCamera3HeapMemory *mStreamInfoBuf; 151 channel_cb_routine mChannelCB; 152 //cam_padding_info_t *mPaddingInfo; 153 uint32_t mPostProcMask; 154 uint32_t mYUVDump; 155 cam_is_type_t mIsType; 156 uint32_t mNumBuffers; 157 /* Enable unmapping of buffer before issuing buffer callback. Default value 158 * for this flag is true and is selectively set to false for the usecases 159 * such as HFR to avoid any performance hit due to mapping/unmapping */ 160 bool mPerFrameMapUnmapEnable; 161 uint32_t frm_num; 162 uint32_t dumpFrmCnt; 163 uint32_t skip_mode; 164 uint32_t mDumpSkipCnt; 165 }; 166 167 /* QCamera3ProcessingChannel is used to handle all streams that are directly 168 * generated by hardware and given to frameworks without any postprocessing at HAL. 169 * It also handles input streams that require reprocessing by hardware and then 170 * returned to frameworks. */ 171 class QCamera3ProcessingChannel : public QCamera3Channel 172 { 173 public: 174 QCamera3ProcessingChannel(uint32_t cam_handle, 175 uint32_t channel_handle, 176 mm_camera_ops_t *cam_ops, 177 channel_cb_routine cb_routine, 178 cam_padding_info_t *paddingInfo, 179 void *userData, 180 camera3_stream_t *stream, 181 cam_stream_type_t stream_type, 182 uint32_t postprocess_mask, 183 QCamera3Channel *metadataChannel, 184 uint32_t numBuffers = MAX_INFLIGHT_REQUESTS); 185 186 ~QCamera3ProcessingChannel(); 187 188 virtual int32_t initialize(cam_is_type_t isType); 189 virtual int32_t request(buffer_handle_t *buffer, 190 uint32_t frameNumber, 191 camera3_stream_buffer_t* pInputBuffer, 192 metadata_buffer_t* metadata); 193 virtual void streamCbRoutine(mm_camera_super_buf_t *super_frame, 194 QCamera3Stream *stream); 195 virtual QCamera3StreamMem *getStreamBufs(uint32_t len); 196 virtual void putStreamBufs(); 197 virtual int32_t registerBuffer(buffer_handle_t *buffer, cam_is_type_t isType); 198 199 virtual int32_t stop(); 200 201 virtual reprocess_type_t getReprocessType() = 0; 202 203 virtual void reprocessCbRoutine(buffer_handle_t *resultBuffer, 204 uint32_t resultFrameNumber); 205 206 int32_t queueReprocMetadata(mm_camera_super_buf_t *metadata); 207 int32_t metadataBufDone(mm_camera_super_buf_t *recvd_frame); 208 int32_t translateStreamTypeAndFormat(camera3_stream_t *stream, 209 cam_stream_type_t &streamType, 210 cam_format_t &streamFormat); 211 int32_t setReprocConfig(reprocess_config_t &reproc_cfg, 212 camera3_stream_buffer_t *pInputBuffer, 213 metadata_buffer_t *metadata, 214 cam_format_t streamFormat, cam_dimension_t dim); 215 int32_t setFwkInputPPData(qcamera_fwk_input_pp_data_t *src_frame, 216 camera3_stream_buffer_t *pInputBuffer, 217 reprocess_config_t *reproc_cfg, 218 metadata_buffer_t *metadata, 219 buffer_handle_t *output_buffer, 220 uint32_t frameNumber); 221 int32_t checkStreamCbErrors(mm_camera_super_buf_t *super_frame, 222 QCamera3Stream *stream); 223 int32_t getStreamSize(cam_dimension_t &dim); 224 225 QCamera3PostProcessor m_postprocessor; // post processor 226 void showDebugFPS(int32_t streamType); 227 228 protected: 229 uint8_t mDebugFPS; 230 int mFrameCount; 231 int mLastFrameCount; 232 nsecs_t mLastFpsTime; isWNREnabled()233 bool isWNREnabled() {return m_bWNROn;}; 234 void startPostProc(const reprocess_config_t &reproc_cfg); 235 void issueChannelCb(buffer_handle_t *resultBuffer, 236 uint32_t resultFrameNumber); 237 int32_t releaseOfflineMemory(uint32_t resultFrameNumber); 238 239 QCamera3StreamMem mMemory; //output buffer allocated by fwk 240 camera3_stream_t *mCamera3Stream; 241 uint32_t mNumBufs; 242 cam_stream_type_t mStreamType; 243 cam_format_t mStreamFormat; 244 uint8_t mIntent; 245 246 bool mPostProcStarted; 247 bool mInputBufferConfig; // Set when the processing channel is configured 248 // for processing input(framework) buffers 249 250 QCamera3Channel *m_pMetaChannel; 251 mm_camera_super_buf_t *mMetaFrame; 252 QCamera3StreamMem mOfflineMemory; //reprocessing input buffer 253 QCamera3StreamMem mOfflineMetaMemory; //reprocessing metadata buffer 254 List<uint32_t> mFreeOfflineMetaBuffersList; 255 Mutex mFreeOfflineMetaBuffersLock; 256 257 private: 258 259 bool m_bWNROn; 260 }; 261 262 /* QCamera3RegularChannel is used to handle all streams that are directly 263 * generated by hardware and given to frameworks without any postprocessing at HAL. 264 * Examples are: all IMPLEMENTATION_DEFINED streams, CPU_READ streams. */ 265 class QCamera3RegularChannel : public QCamera3ProcessingChannel 266 { 267 public: 268 QCamera3RegularChannel(uint32_t cam_handle, 269 uint32_t channel_handle, 270 mm_camera_ops_t *cam_ops, 271 channel_cb_routine cb_routine, 272 cam_padding_info_t *paddingInfo, 273 void *userData, 274 camera3_stream_t *stream, 275 cam_stream_type_t stream_type, 276 uint32_t postprocess_mask, 277 QCamera3Channel *metadataChannel, 278 uint32_t numBuffers = MAX_INFLIGHT_REQUESTS); 279 280 virtual ~QCamera3RegularChannel(); 281 282 virtual int32_t setBatchSize(uint32_t batchSize); 283 virtual uint32_t getStreamTypeMask(); 284 virtual int32_t queueBatchBuf(); 285 virtual int32_t initialize(cam_is_type_t isType); 286 using QCamera3ProcessingChannel::request; 287 virtual int32_t request(buffer_handle_t *buffer, uint32_t frameNumber); 288 virtual reprocess_type_t getReprocessType(); 289 290 private: 291 int32_t initialize(struct private_handle_t *priv_handle); 292 293 uint32_t mBatchSize; 294 cam_rotation_t mRotation; 295 }; 296 297 /* QCamera3MetadataChannel is for metadata stream generated by camera daemon. */ 298 class QCamera3MetadataChannel : public QCamera3Channel 299 { 300 public: 301 QCamera3MetadataChannel(uint32_t cam_handle, 302 uint32_t channel_handle, 303 mm_camera_ops_t *cam_ops, 304 channel_cb_routine cb_routine, 305 cam_padding_info_t *paddingInfo, 306 uint32_t postprocess_mask, 307 void *userData, 308 uint32_t numBuffers = MIN_STREAMING_BUFFER_NUM); 309 virtual ~QCamera3MetadataChannel(); 310 311 virtual int32_t initialize(cam_is_type_t isType); 312 313 virtual int32_t request(buffer_handle_t *buffer, uint32_t frameNumber); 314 virtual void streamCbRoutine(mm_camera_super_buf_t *super_frame, 315 QCamera3Stream *stream); 316 317 virtual QCamera3StreamMem *getStreamBufs(uint32_t le); 318 virtual void putStreamBufs(); registerBuffer(buffer_handle_t *,cam_is_type_t)319 virtual int32_t registerBuffer(buffer_handle_t * /*buffer*/, cam_is_type_t /*isType*/) 320 { return NO_ERROR; }; 321 322 private: 323 QCamera3StreamMem *mMemory; 324 }; 325 326 /* QCamera3RawChannel is for opaqueu/cross-platform raw stream containing 327 * vendor specific bayer data or 16-bit unpacked bayer data */ 328 class QCamera3RawChannel : public QCamera3RegularChannel 329 { 330 public: 331 QCamera3RawChannel(uint32_t cam_handle, 332 uint32_t channel_handle, 333 mm_camera_ops_t *cam_ops, 334 channel_cb_routine cb_routine, 335 cam_padding_info_t *paddingInfo, 336 void *userData, 337 camera3_stream_t *stream, 338 uint32_t postprocess_mask, 339 QCamera3Channel *metadataChannel, 340 bool raw_16 = false, 341 uint32_t numBuffers = MAX_INFLIGHT_REQUESTS); 342 343 virtual ~QCamera3RawChannel(); 344 345 virtual int32_t initialize(cam_is_type_t isType); 346 347 virtual void streamCbRoutine(mm_camera_super_buf_t *super_frame, 348 QCamera3Stream *stream); 349 350 virtual reprocess_type_t getReprocessType(); 351 352 private: 353 bool mRawDump; 354 bool mIsRaw16; 355 356 void dumpRawSnapshot(mm_camera_buf_def_t *frame); 357 void convertLegacyToRaw16(mm_camera_buf_def_t *frame); 358 void convertMipiToRaw16(mm_camera_buf_def_t *frame); 359 }; 360 361 /* 362 * QCamera3RawDumpChannel is for internal use only for Raw dump 363 */ 364 365 class QCamera3RawDumpChannel : public QCamera3Channel 366 { 367 public: 368 QCamera3RawDumpChannel(uint32_t cam_handle, 369 uint32_t channel_handle, 370 mm_camera_ops_t *cam_ops, 371 cam_dimension_t rawDumpSize, 372 cam_padding_info_t *paddingInfo, 373 void *userData, 374 uint32_t postprocess_mask, uint32_t numBuffers = 3U); 375 virtual ~QCamera3RawDumpChannel(); 376 virtual int32_t initialize(cam_is_type_t isType); 377 virtual void streamCbRoutine(mm_camera_super_buf_t *super_frame, 378 QCamera3Stream *stream); 379 virtual QCamera3StreamMem *getStreamBufs(uint32_t le); 380 virtual void putStreamBufs(); registerBuffer(buffer_handle_t *,cam_is_type_t)381 virtual int32_t registerBuffer(buffer_handle_t * /*buffer*/, cam_is_type_t /*isType*/) 382 { return NO_ERROR; }; 383 virtual int32_t request(buffer_handle_t *buffer, uint32_t frameNumber); 384 void dumpRawSnapshot(mm_camera_buf_def_t *frame); 385 386 public: 387 cam_dimension_t mDim; 388 389 private: 390 bool mRawDump; 391 QCamera3StreamMem *mMemory; 392 }; 393 394 /* QCamera3YUVChannel is used to handle flexible YUV streams that are directly 395 * generated by hardware and given to frameworks without any postprocessing at HAL. 396 * It is also used to handle input buffers that generate YUV outputs */ 397 class QCamera3YUVChannel : public QCamera3ProcessingChannel 398 { 399 public: 400 QCamera3YUVChannel(uint32_t cam_handle, 401 uint32_t channel_handle, 402 mm_camera_ops_t *cam_ops, 403 channel_cb_routine cb_routine, 404 cam_padding_info_t *paddingInfo, 405 void *userData, 406 camera3_stream_t *stream, 407 cam_stream_type_t stream_type, 408 uint32_t postprocess_mask, 409 QCamera3Channel *metadataChannel); 410 ~QCamera3YUVChannel(); 411 virtual int32_t initialize(cam_is_type_t isType); 412 using QCamera3ProcessingChannel::request; 413 virtual int32_t request(buffer_handle_t *buffer, 414 uint32_t frameNumber, 415 camera3_stream_buffer_t* pInputBuffer, 416 metadata_buffer_t* metadata, bool &needMetadata); 417 virtual reprocess_type_t getReprocessType(); 418 virtual void streamCbRoutine(mm_camera_super_buf_t *super_frame, 419 QCamera3Stream *stream); 420 virtual void putStreamBufs(); 421 virtual void reprocessCbRoutine(buffer_handle_t *resultBuffer, 422 uint32_t resultFrameNumber); 423 424 private: 425 typedef struct { 426 uint32_t frameNumber; 427 bool offlinePpFlag; 428 buffer_handle_t *output; 429 mm_camera_super_buf_t *callback_buffer; 430 } PpInfo; 431 432 // Whether offline postprocessing is required for this channel 433 bool mBypass; 434 uint32_t mFrameLen; 435 436 // Current edge, noise, and crop region setting 437 cam_edge_application_t mEdgeMode; 438 uint32_t mNoiseRedMode; 439 cam_crop_region_t mCropRegion; 440 441 // Mutex to protect mOfflinePpFlagMap and mFreeHeapBufferList 442 Mutex mOfflinePpLock; 443 // Map between free number and whether the request needs to be 444 // postprocessed. 445 List<PpInfo> mOfflinePpInfoList; 446 // Heap buffer index list 447 List<uint32_t> mFreeHeapBufferList; 448 449 private: 450 bool needsFramePostprocessing(metadata_buffer_t* meta); 451 int32_t handleOfflinePpCallback(uint32_t resultFrameNumber, 452 Vector<mm_camera_super_buf_t *>& pendingCbs); 453 }; 454 455 /* QCamera3PicChannel is for JPEG stream, which contains a YUV stream generated 456 * by the hardware, and encoded to a JPEG stream */ 457 class QCamera3PicChannel : public QCamera3ProcessingChannel 458 { 459 public: 460 QCamera3PicChannel(uint32_t cam_handle, 461 uint32_t channel_handle, 462 mm_camera_ops_t *cam_ops, 463 channel_cb_routine cb_routine, 464 cam_padding_info_t *paddingInfo, 465 void *userData, 466 camera3_stream_t *stream, 467 uint32_t postprocess_mask, 468 bool is4KVideo, 469 bool isInputStreamConfigured, 470 QCamera3Channel *metadataChannel, 471 uint32_t numBuffers = MAX_INFLIGHT_REQUESTS); 472 ~QCamera3PicChannel(); 473 474 virtual int32_t initialize(cam_is_type_t isType); 475 virtual int32_t flush(); 476 virtual int32_t request(buffer_handle_t *buffer, 477 uint32_t frameNumber, 478 camera3_stream_buffer_t* pInputBuffer, 479 metadata_buffer_t* metadata); 480 virtual void streamCbRoutine(mm_camera_super_buf_t *super_frame, 481 QCamera3Stream *stream); 482 483 virtual QCamera3StreamMem *getStreamBufs(uint32_t le); 484 virtual void putStreamBufs(); 485 virtual reprocess_type_t getReprocessType(); 486 487 QCamera3Exif *getExifData(metadata_buffer_t *metadata, 488 jpeg_settings_t *jpeg_settings); 489 void overrideYuvSize(uint32_t width, uint32_t height); 490 static void jpegEvtHandle(jpeg_job_status_t status, 491 uint32_t /*client_hdl*/, 492 uint32_t jobId, 493 mm_jpeg_output_t *p_output, 494 void *userdata); 495 static void dataNotifyCB(mm_camera_super_buf_t *recvd_frame, 496 void *userdata); 497 498 private: 499 int32_t queueJpegSetting(uint32_t out_buf_index, metadata_buffer_t *metadata); 500 501 public: 502 cam_dimension_t m_max_pic_dim; 503 504 private: 505 uint32_t mNumSnapshotBufs; 506 uint32_t mYuvWidth, mYuvHeight; 507 int32_t mCurrentBufIndex; 508 bool mInputBufferHint; 509 QCamera3StreamMem *mYuvMemory; 510 // Keep a list of free buffers 511 Mutex mFreeBuffersLock; 512 List<uint32_t> mFreeBufferList; 513 uint32_t mFrameLen; 514 }; 515 516 // reprocess channel class 517 class QCamera3ReprocessChannel : public QCamera3Channel 518 { 519 public: 520 QCamera3ReprocessChannel(uint32_t cam_handle, 521 uint32_t channel_handle, 522 mm_camera_ops_t *cam_ops, 523 channel_cb_routine cb_routine, 524 cam_padding_info_t *paddingInfo, 525 uint32_t postprocess_mask, 526 void *userData, void *ch_hdl); 527 QCamera3ReprocessChannel(); 528 virtual ~QCamera3ReprocessChannel(); 529 // offline reprocess 530 virtual int32_t start(); 531 virtual int32_t stop(); 532 int32_t doReprocessOffline(qcamera_fwk_input_pp_data_t *frame, 533 bool isPriorityFrame = false); 534 int32_t doReprocess(int buf_fd, size_t buf_length, int32_t &ret_val, 535 mm_camera_super_buf_t *meta_buf); 536 int32_t overrideMetadata(qcamera_hal3_pp_buffer_t *pp_buffer, 537 mm_camera_buf_def_t *meta_buffer, 538 jpeg_settings_t *jpeg_settings, 539 qcamera_fwk_input_pp_data_t &fwk_frame); 540 int32_t overrideFwkMetadata(qcamera_fwk_input_pp_data_t *frame); 541 virtual QCamera3StreamMem *getStreamBufs(uint32_t len); 542 virtual void putStreamBufs(); 543 virtual int32_t initialize(cam_is_type_t isType); 544 int32_t unmapOfflineBuffers(bool all); 545 int32_t bufDone(mm_camera_super_buf_t *recvd_frame); 546 virtual void streamCbRoutine(mm_camera_super_buf_t *super_frame, 547 QCamera3Stream *stream); 548 static void dataNotifyCB(mm_camera_super_buf_t *recvd_frame, 549 void* userdata); 550 int32_t addReprocStreamsFromSource(cam_pp_feature_config_t &pp_config, 551 const reprocess_config_t &src_config, 552 cam_is_type_t is_type, 553 QCamera3Channel *pMetaChannel); 554 QCamera3Stream *getStreamBySrcHandle(uint32_t srcHandle); 555 QCamera3Stream *getSrcStreamBySrcHandle(uint32_t srcHandle); 556 virtual int32_t registerBuffer(buffer_handle_t * buffer, cam_is_type_t isType); 557 558 public: 559 void *inputChHandle; 560 561 private: 562 typedef struct { 563 QCamera3Stream *stream; 564 cam_mapping_buf_type type; 565 uint32_t index; 566 } OfflineBuffer; 567 568 int32_t resetToCamPerfNormal(uint32_t frameNumber); 569 android::List<OfflineBuffer> mOfflineBuffers; 570 android::List<OfflineBuffer> mOfflineMetaBuffers; 571 int32_t mOfflineBuffersIndex; 572 int32_t mOfflineMetaIndex; 573 uint32_t mFrameLen; 574 Mutex mFreeBuffersLock; // Lock for free heap buffers 575 List<int32_t> mFreeBufferList; // Free heap buffers list 576 reprocess_type_t mReprocessType; 577 uint32_t mSrcStreamHandles[MAX_STREAM_NUM_IN_BUNDLE]; 578 QCamera3ProcessingChannel *m_pSrcChannel; // ptr to source channel for reprocess 579 QCamera3Channel *m_pMetaChannel; 580 QCamera3StreamMem *mMemory; 581 QCamera3StreamMem mGrallocMemory; 582 Vector<uint32_t> mPriorityFrames; 583 Mutex mPriorityFramesLock; 584 bool mReprocessPerfMode; 585 }; 586 587 588 /* QCamera3SupportChannel is for HAL internal consumption only */ 589 class QCamera3SupportChannel : public QCamera3Channel 590 { 591 public: 592 QCamera3SupportChannel(uint32_t cam_handle, 593 uint32_t channel_handle, 594 mm_camera_ops_t *cam_ops, 595 cam_padding_info_t *paddingInfo, 596 uint32_t postprocess_mask, 597 cam_stream_type_t streamType, 598 cam_dimension_t *dim, 599 cam_format_t streamFormat, 600 uint8_t hw_analysis_supported, 601 void *userData, 602 uint32_t numBuffers = MIN_STREAMING_BUFFER_NUM 603 ); 604 virtual ~QCamera3SupportChannel(); 605 606 virtual int32_t initialize(cam_is_type_t isType); 607 608 virtual int32_t request(buffer_handle_t *buffer, uint32_t frameNumber); 609 virtual void streamCbRoutine(mm_camera_super_buf_t *super_frame, 610 QCamera3Stream *stream); 611 612 virtual QCamera3StreamMem *getStreamBufs(uint32_t le); 613 virtual void putStreamBufs(); registerBuffer(buffer_handle_t *,cam_is_type_t)614 virtual int32_t registerBuffer(buffer_handle_t * /*buffer*/, cam_is_type_t /*isType*/) 615 { return NO_ERROR; }; 616 617 static cam_dimension_t kDim; 618 private: 619 QCamera3StreamMem *mMemory; 620 cam_dimension_t mDim; 621 cam_stream_type_t mStreamType; 622 cam_format_t mStreamFormat; 623 }; 624 625 }; // namespace qcamera 626 627 #endif /* __QCAMERA_CHANNEL_H__ */ 628